Skip to content

Commit 03742ae

Browse files
committed
ra: Don't expect or validate contactsPresent
1 parent e005f21 commit 03742ae

File tree

2 files changed

+4
-91
lines changed

2 files changed

+4
-91
lines changed

ra/ra.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -381,22 +381,17 @@ func (ra *RegistrationAuthorityImpl) NewRegistration(ctx context.Context, reques
381381
}
382382

383383
// Check that contacts conform to our expectations.
384-
err = validateContactsPresent(request.Contact, request.ContactsPresent)
385-
if err != nil {
386-
return nil, err
387-
}
388384
err = ra.validateContacts(request.Contact)
389385
if err != nil {
390386
return nil, err
391387
}
392388

393389
// Don't populate ID or CreatedAt because those will be set by the SA.
394390
req := &corepb.Registration{
395-
Key: request.Key,
396-
Contact: request.Contact,
397-
ContactsPresent: request.ContactsPresent,
398-
Agreement: request.Agreement,
399-
Status: string(core.StatusValid),
391+
Key: request.Key,
392+
Contact: request.Contact,
393+
Agreement: request.Agreement,
394+
Status: string(core.StatusValid),
400395
}
401396

402397
// Store the registration object, then return the version that got stored.
@@ -2314,20 +2309,6 @@ func wildcardOverlap(dnsNames []string) error {
23142309
return nil
23152310
}
23162311

2317-
// validateContactsPresent will return an error if the contacts []string
2318-
// len is greater than zero and the contactsPresent bool is false. We
2319-
// don't care about any other cases. If the length of the contacts is zero
2320-
// and contactsPresent is true, it seems like a mismatch but we have to
2321-
// assume that the client is requesting to update the contacts field with
2322-
// by removing the existing contacts value so we don't want to return an
2323-
// error here.
2324-
func validateContactsPresent(contacts []string, contactsPresent bool) error {
2325-
if len(contacts) > 0 && !contactsPresent {
2326-
return berrors.InternalServerError("account contacts present but contactsPresent false")
2327-
}
2328-
return nil
2329-
}
2330-
23312312
// UnpauseAccount receives a validated account unpause request from the SFE and
23322313
// instructs the SA to unpause that account. If the account cannot be unpaused,
23332314
// an error is returned.

ra/ra_test.go

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,6 @@ var (
258258

259259
var ctx = context.Background()
260260

261-
func newAcctKey(t *testing.T) []byte {
262-
key, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
263-
jwk := &jose.JSONWebKey{Key: key.Public()}
264-
acctKey, err := jwk.MarshalJSON()
265-
test.AssertNotError(t, err, "failed to marshal account key")
266-
return acctKey
267-
}
268-
269261
func initAuthorities(t *testing.T) (*DummyValidationAuthority, sapb.StorageAuthorityClient, *RegistrationAuthorityImpl, ratelimits.Source, clock.FakeClock, func()) {
270262
err := json.Unmarshal(AccountKeyJSONA, &AccountKeyA)
271263
test.AssertNotError(t, err, "Failed to unmarshal public JWK")
@@ -464,66 +456,6 @@ func TestNewRegistration(t *testing.T) {
464456
test.AssertByteEquals(t, reg.Key, acctKeyB)
465457
}
466458

467-
func TestNewRegistrationContactsPresent(t *testing.T) {
468-
_, _, ra, _, _, cleanUp := initAuthorities(t)
469-
defer cleanUp()
470-
testCases := []struct {
471-
Name string
472-
Reg *corepb.Registration
473-
ExpectedErr error
474-
}{
475-
{
476-
Name: "No contacts provided by client ContactsPresent false",
477-
Reg: &corepb.Registration{
478-
Key: newAcctKey(t),
479-
},
480-
ExpectedErr: nil,
481-
},
482-
{
483-
Name: "Empty contact provided by client ContactsPresent true",
484-
Reg: &corepb.Registration{
485-
Contact: []string{},
486-
ContactsPresent: true,
487-
Key: newAcctKey(t),
488-
},
489-
ExpectedErr: nil,
490-
},
491-
{
492-
Name: "Valid contact provided by client ContactsPresent true",
493-
Reg: &corepb.Registration{
494-
Contact: []string{"mailto:foo@letsencrypt.org"},
495-
ContactsPresent: true,
496-
Key: newAcctKey(t),
497-
},
498-
ExpectedErr: nil,
499-
},
500-
{
501-
Name: "Valid contact provided by client ContactsPresent false",
502-
Reg: &corepb.Registration{
503-
Contact: []string{"mailto:foo@letsencrypt.org"},
504-
ContactsPresent: false,
505-
Key: newAcctKey(t),
506-
},
507-
ExpectedErr: fmt.Errorf("account contacts present but contactsPresent false"),
508-
},
509-
}
510-
// For each test case we check that the NewRegistration works as
511-
// intended with variations of Contact and ContactsPresent fields
512-
for _, tc := range testCases {
513-
t.Run(tc.Name, func(t *testing.T) {
514-
// Create new registration
515-
_, err := ra.NewRegistration(ctx, tc.Reg)
516-
// Check error output
517-
if tc.ExpectedErr == nil {
518-
test.AssertNotError(t, err, "expected no error for NewRegistration")
519-
} else {
520-
test.AssertError(t, err, "expected error for NewRegistration")
521-
test.AssertEquals(t, err.Error(), tc.ExpectedErr.Error())
522-
}
523-
})
524-
}
525-
}
526-
527459
type mockSAFailsNewRegistration struct {
528460
sapb.StorageAuthorityClient
529461
}

0 commit comments

Comments
 (0)