diff --git a/sa/database.go b/sa/database.go index 98f722eaa..214c2215d 100644 --- a/sa/database.go +++ b/sa/database.go @@ -264,8 +264,6 @@ func initTables(dbMap *gorp.DbMap) { regTable.SetVersionCol("LockCol") regTable.ColMap("Key").SetNotNull(true) regTable.ColMap("KeySHA256").SetNotNull(true).SetUnique(true) - dbMap.AddTableWithName(authzModel{}, "authz").SetKeys(false, "ID") - dbMap.AddTableWithName(challModel{}, "challenges").SetKeys(true, "ID") dbMap.AddTableWithName(issuedNameModel{}, "issuedNames").SetKeys(true, "ID") dbMap.AddTableWithName(core.Certificate{}, "certificates").SetKeys(true, "ID") dbMap.AddTableWithName(core.CertificateStatus{}, "certificateStatus").SetKeys(true, "ID") diff --git a/sa/model.go b/sa/model.go index 577fded83..7062942b4 100644 --- a/sa/model.go +++ b/sa/model.go @@ -225,25 +225,6 @@ type regModel struct { Status string `db:"status"` } -// challModel is the description of a core.Challenge in the database -// -// The Validation field is a stub; the column is only there for backward compatibility. -type challModel struct { - ID int64 `db:"id"` - AuthorizationID string `db:"authorizationID"` - - Type core.AcmeChallenge `db:"type"` - Status core.AcmeStatus `db:"status"` - Error []byte `db:"error"` - Token string `db:"token"` - KeyAuthorization string `db:"keyAuthorization"` - ValidationRecord []byte `db:"validationRecord"` - AttemptedAt time.Time `db:"attemptedAt"` - - // TODO(#1818): Remove, this field is unused, but is kept temporarily to avoid a database migration. - Validated bool `db:"validated"` -} - func registrationPbToModel(reg *corepb.Registration) (*regModel, error) { // Even though we don't need to convert from JSON to an in-memory JSONWebKey // for the sake of the `Key` field, we do need to do the conversion in order @@ -319,39 +300,6 @@ func registrationModelToPb(reg *regModel) (*corepb.Registration, error) { }, nil } -func modelToChallenge(cm *challModel) (core.Challenge, error) { - c := core.Challenge{ - Type: cm.Type, - Status: cm.Status, - Token: cm.Token, - ProvidedKeyAuthorization: cm.KeyAuthorization, - Validated: &cm.AttemptedAt, - } - if len(cm.Error) > 0 { - var problem probs.ProblemDetails - err := json.Unmarshal(cm.Error, &problem) - if err != nil { - return core.Challenge{}, badJSONError( - "failed to unmarshal challenge model's error", - cm.Error, - err) - } - c.Error = &problem - } - if len(cm.ValidationRecord) > 0 { - var vr []core.ValidationRecord - err := json.Unmarshal(cm.ValidationRecord, &vr) - if err != nil { - return core.Challenge{}, badJSONError( - "failed to unmarshal challenge model's validation record", - cm.ValidationRecord, - err) - } - c.ValidationRecord = vr - } - return c, nil -} - type recordedSerialModel struct { ID int64 Serial string diff --git a/sa/model_test.go b/sa/model_test.go index 7395825cc..6453d8c08 100644 --- a/sa/model_test.go +++ b/sa/model_test.go @@ -146,40 +146,6 @@ func TestAuthzModel(t *testing.T) { test.AssertError(t, err, "authzPBToModel didn't fail with multiple non-pending challenges") } -// TestModelToChallengeBadJSON tests that converting a challenge model with an -// invalid validation error field or validation record field produces the -// expected bad JSON error. -func TestModelToChallengeBadJSON(t *testing.T) { - badJSON := []byte(`{`) - - testCases := []struct { - Name string - Model *challModel - }{ - { - Name: "Bad error field", - Model: &challModel{ - Error: badJSON, - }, - }, - { - Name: "Bad validation record field", - Model: &challModel{ - ValidationRecord: badJSON, - }, - }, - } - for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { - _, err := modelToChallenge(tc.Model) - test.AssertError(t, err, "expected error from modelToChallenge") - var badJSONErr errBadJSON - test.AssertErrorWraps(t, err, &badJSONErr) - test.AssertEquals(t, string(badJSONErr.json), string(badJSON)) - }) - } -} - // TestModelToOrderBADJSON tests that converting an order model with an invalid // validation error JSON field to an Order produces the expected bad JSON error. func TestModelToOrderBadJSON(t *testing.T) {