parent
c2156479dd
commit
02864c11bf
|
|
@ -206,7 +206,7 @@ func (sa *StorageAuthority) GetRegistrationByKey(_ context.Context, jwk *jose.JS
|
|||
}
|
||||
|
||||
// Return a fake registration. Make sure to fill the key field to avoid marshaling errors.
|
||||
return core.Registration{ID: 1, Key: &test1KeyPublic, Agreement: agreementURL}, nil
|
||||
return core.Registration{ID: 1, Key: &test1KeyPublic, Agreement: agreementURL, Status: core.StatusValid}, nil
|
||||
}
|
||||
|
||||
// GetAuthorization is a mock
|
||||
|
|
|
|||
|
|
@ -1649,8 +1649,6 @@ func TestDeactivateAuthorization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeactivateRegistration(t *testing.T) {
|
||||
_ = features.Set(map[string]bool{"AllowAccountDeactivation": true})
|
||||
defer features.Reset()
|
||||
_, _, ra, _, cleanUp := initAuthorities(t)
|
||||
defer cleanUp()
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
"gopkg.in/go-gorp/gorp.v2"
|
||||
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
"github.com/letsencrypt/boulder/features"
|
||||
blog "github.com/letsencrypt/boulder/log"
|
||||
"github.com/letsencrypt/boulder/metrics"
|
||||
)
|
||||
|
|
@ -179,11 +178,8 @@ func ReportDbConnCount(dbMap *gorp.DbMap, statter metrics.Scope) {
|
|||
// https://godoc.org/github.com/coopernurse/gorp#DbMap.Insert
|
||||
func initTables(dbMap *gorp.DbMap) {
|
||||
var regTable *gorp.TableMap
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
regTable = dbMap.AddTableWithName(regModelv2{}, "registrations").SetKeys(true, "ID")
|
||||
} else {
|
||||
regTable = dbMap.AddTableWithName(regModelv1{}, "registrations").SetKeys(true, "ID")
|
||||
}
|
||||
regTable = dbMap.AddTableWithName(regModelv2{}, "registrations").SetKeys(true, "ID")
|
||||
|
||||
regTable.SetVersionCol("LockCol")
|
||||
regTable.ColMap("Key").SetNotNull(true)
|
||||
regTable.ColMap("KeySHA256").SetNotNull(true).SetUnique(true)
|
||||
|
|
|
|||
28
sa/model.go
28
sa/model.go
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
corepb "github.com/letsencrypt/boulder/core/proto"
|
||||
"github.com/letsencrypt/boulder/features"
|
||||
"github.com/letsencrypt/boulder/probs"
|
||||
"github.com/letsencrypt/boulder/revocation"
|
||||
)
|
||||
|
|
@ -242,23 +241,18 @@ func registrationToModel(r *core.Registration) (interface{}, error) {
|
|||
InitialIP: []byte(r.InitialIP.To16()),
|
||||
CreatedAt: r.CreatedAt,
|
||||
}
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
return ®Modelv2{
|
||||
regModelv1: rm,
|
||||
Status: string(r.Status),
|
||||
}, nil
|
||||
}
|
||||
return &rm, nil
|
||||
|
||||
return ®Modelv2{
|
||||
regModelv1: rm,
|
||||
Status: string(r.Status),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func modelToRegistration(ri interface{}) (core.Registration, error) {
|
||||
var rm *regModelv1
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
r2 := ri.(*regModelv2)
|
||||
rm = &r2.regModelv1
|
||||
} else {
|
||||
rm = ri.(*regModelv1)
|
||||
}
|
||||
r2 := ri.(*regModelv2)
|
||||
rm = &r2.regModelv1
|
||||
|
||||
k := &jose.JSONWebKey{}
|
||||
err := json.Unmarshal(rm.Key, k)
|
||||
if err != nil {
|
||||
|
|
@ -281,11 +275,9 @@ func modelToRegistration(ri interface{}) (core.Registration, error) {
|
|||
Agreement: rm.Agreement,
|
||||
InitialIP: net.IP(rm.InitialIP),
|
||||
CreatedAt: rm.CreatedAt,
|
||||
Status: core.AcmeStatus(r2.Status),
|
||||
}
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
r2 := ri.(*regModelv2)
|
||||
r.Status = core.AcmeStatus(r2.Status)
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,9 @@ package sa
|
|||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/letsencrypt/boulder/features"
|
||||
)
|
||||
|
||||
func TestModelToRegistrationNilContact(t *testing.T) {
|
||||
_ = features.Set(map[string]bool{"AllowAccountDeactivation": true})
|
||||
defer features.Reset()
|
||||
reg, err := modelToRegistration(®Modelv2{
|
||||
regModelv1: regModelv1{
|
||||
Key: []byte(`{"kty":"RSA","n":"AQAB","e":"AQAB"}`),
|
||||
|
|
@ -26,8 +22,6 @@ func TestModelToRegistrationNilContact(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestModelToRegistrationNonNilContact(t *testing.T) {
|
||||
_ = features.Set(map[string]bool{"AllowAccountDeactivation": true})
|
||||
defer features.Reset()
|
||||
reg, err := modelToRegistration(®Modelv2{
|
||||
regModelv1: regModelv1{
|
||||
Key: []byte(`{"kty":"RSA","n":"AQAB","e":"AQAB"}`),
|
||||
|
|
|
|||
34
sa/sa.go
34
sa/sa.go
|
|
@ -125,11 +125,8 @@ func (ssa *SQLStorageAuthority) GetRegistration(ctx context.Context, id int64) (
|
|||
const query = "WHERE id = ?"
|
||||
var model interface{}
|
||||
var err error
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
model, err = selectRegistrationv2(ssa.dbMap, query, id)
|
||||
} else {
|
||||
model, err = selectRegistration(ssa.dbMap, query, id)
|
||||
}
|
||||
model, err = selectRegistrationv2(ssa.dbMap, query, id)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
return core.Registration{}, berrors.NotFoundError("registration with ID '%d' not found", id)
|
||||
}
|
||||
|
|
@ -151,11 +148,7 @@ func (ssa *SQLStorageAuthority) GetRegistrationByKey(ctx context.Context, key *j
|
|||
if err != nil {
|
||||
return core.Registration{}, err
|
||||
}
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
model, err = selectRegistrationv2(ssa.dbMap, query, sha)
|
||||
} else {
|
||||
model, err = selectRegistration(ssa.dbMap, query, sha)
|
||||
}
|
||||
model, err = selectRegistrationv2(ssa.dbMap, query, sha)
|
||||
if err == sql.ErrNoRows {
|
||||
return core.Registration{}, berrors.NotFoundError("no registrations with public key sha256 %q", sha)
|
||||
}
|
||||
|
|
@ -631,11 +624,7 @@ func (ssa *SQLStorageAuthority) UpdateRegistration(ctx context.Context, reg core
|
|||
const query = "WHERE id = ?"
|
||||
var model interface{}
|
||||
var err error
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
model, err = selectRegistrationv2(ssa.dbMap, query, reg.ID)
|
||||
} else {
|
||||
model, err = selectRegistration(ssa.dbMap, query, reg.ID)
|
||||
}
|
||||
model, err = selectRegistrationv2(ssa.dbMap, query, reg.ID)
|
||||
if err == sql.ErrNoRows {
|
||||
return berrors.NotFoundError("registration with ID '%d' not found", reg.ID)
|
||||
}
|
||||
|
|
@ -649,17 +638,10 @@ func (ssa *SQLStorageAuthority) UpdateRegistration(ctx context.Context, reg core
|
|||
// version we need to cast both the updated and existing model to their proper types
|
||||
// so that we can copy over the LockCol from one to the other. Once we have copied
|
||||
// that field we reassign to the interface so gorp can properly update it.
|
||||
if features.Enabled(features.AllowAccountDeactivation) {
|
||||
erm := model.(*regModelv2)
|
||||
urm := updatedRegModel.(*regModelv2)
|
||||
urm.LockCol = erm.LockCol
|
||||
updatedRegModel = urm
|
||||
} else {
|
||||
erm := model.(*regModelv1)
|
||||
urm := updatedRegModel.(*regModelv1)
|
||||
urm.LockCol = erm.LockCol
|
||||
updatedRegModel = urm
|
||||
}
|
||||
erm := model.(*regModelv2)
|
||||
urm := updatedRegModel.(*regModelv2)
|
||||
urm.LockCol = erm.LockCol
|
||||
updatedRegModel = urm
|
||||
|
||||
n, err := ssa.dbMap.Update(updatedRegModel)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1061,8 +1061,6 @@ func TestDeactivateAuthorization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeactivateAccount(t *testing.T) {
|
||||
_ = features.Set(map[string]bool{"AllowAccountDeactivation": true})
|
||||
defer features.Reset()
|
||||
sa, _, cleanUp := initSA(t)
|
||||
defer cleanUp()
|
||||
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ func (wfe *WebFrontEndImpl) verifyPOST(ctx context.Context, logEvent *requestEve
|
|||
}
|
||||
|
||||
// Only check for validity if we are actually checking the registration
|
||||
if regCheck && features.Enabled(features.AllowAccountDeactivation) && reg.Status != core.StatusValid {
|
||||
if regCheck && reg.Status != core.StatusValid {
|
||||
return nil, nil, reg, probs.Unauthorized(fmt.Sprintf("Registration is not valid, has status '%s'", reg.Status))
|
||||
}
|
||||
|
||||
|
|
@ -1233,7 +1233,7 @@ func (wfe *WebFrontEndImpl) Registration(ctx context.Context, logEvent *requestE
|
|||
// If a user tries to send both a deactivation request and an update to their
|
||||
// contacts or subscriber agreement URL the deactivation will take place and
|
||||
// return before an update would be performed.
|
||||
if features.Enabled(features.AllowAccountDeactivation) && (update.Status != "" && update.Status != currReg.Status) {
|
||||
if update.Status != "" && update.Status != currReg.Status {
|
||||
if update.Status != core.StatusDeactivated {
|
||||
wfe.sendError(response, logEvent, probs.Malformed("Invalid value provided for status field"), nil)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
jose "gopkg.in/square/go-jose.v2"
|
||||
"gopkg.in/square/go-jose.v2"
|
||||
|
||||
"github.com/jmhodges/clock"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
|
|
@ -2098,8 +2098,6 @@ func TestDeactivateAuthorization(t *testing.T) {
|
|||
func TestDeactivateRegistration(t *testing.T) {
|
||||
responseWriter := httptest.NewRecorder()
|
||||
wfe, _ := setupWFE(t)
|
||||
_ = features.Set(map[string]bool{"AllowAccountDeactivation": true})
|
||||
defer features.Reset()
|
||||
|
||||
responseWriter.Body.Reset()
|
||||
wfe.Registration(ctx, newRequestEvent(), responseWriter,
|
||||
|
|
@ -2175,8 +2173,6 @@ func TestDeactivateRegistration(t *testing.T) {
|
|||
func TestKeyRollover(t *testing.T) {
|
||||
responseWriter := httptest.NewRecorder()
|
||||
wfe, _ := setupWFE(t)
|
||||
_ = features.Set(map[string]bool{"AllowAccountDeactivation": true})
|
||||
defer features.Reset()
|
||||
|
||||
key := loadPrivateKey(t, []byte(test3KeyPrivatePEM))
|
||||
rsaKey, ok := key.(*rsa.PrivateKey)
|
||||
|
|
|
|||
Loading…
Reference in New Issue