Remove old challModel code (#6048)

This is no longer needed since the move to authz2.
This commit is contained in:
Jacob Hoffman-Andrews 2022-04-13 16:26:17 -07:00 committed by GitHub
parent ca29b4b380
commit 42c6eacd0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 88 deletions

View File

@ -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")

View File

@ -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

View File

@ -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) {