-
-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ra, pb: Don't expect or validate contactsPresent (#7933)
Part of #7920 There will be a followup removing the remaining places that set `contactsPresent`. --------- Co-authored-by: Jacob Hoffman-Andrews <[email protected]>
- Loading branch information
Showing
4 changed files
with
9 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,14 +258,6 @@ var ( | |
|
||
var ctx = context.Background() | ||
|
||
func newAcctKey(t *testing.T) []byte { | ||
key, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) | ||
jwk := &jose.JSONWebKey{Key: key.Public()} | ||
acctKey, err := jwk.MarshalJSON() | ||
test.AssertNotError(t, err, "failed to marshal account key") | ||
return acctKey | ||
} | ||
|
||
func initAuthorities(t *testing.T) (*DummyValidationAuthority, sapb.StorageAuthorityClient, *RegistrationAuthorityImpl, ratelimits.Source, clock.FakeClock, func()) { | ||
err := json.Unmarshal(AccountKeyJSONA, &AccountKeyA) | ||
test.AssertNotError(t, err, "Failed to unmarshal public JWK") | ||
|
@@ -464,66 +456,6 @@ func TestNewRegistration(t *testing.T) { | |
test.AssertByteEquals(t, reg.Key, acctKeyB) | ||
} | ||
|
||
func TestNewRegistrationContactsPresent(t *testing.T) { | ||
_, _, ra, _, _, cleanUp := initAuthorities(t) | ||
defer cleanUp() | ||
testCases := []struct { | ||
Name string | ||
Reg *corepb.Registration | ||
ExpectedErr error | ||
}{ | ||
{ | ||
Name: "No contacts provided by client ContactsPresent false", | ||
Reg: &corepb.Registration{ | ||
Key: newAcctKey(t), | ||
}, | ||
ExpectedErr: nil, | ||
}, | ||
{ | ||
Name: "Empty contact provided by client ContactsPresent true", | ||
Reg: &corepb.Registration{ | ||
Contact: []string{}, | ||
ContactsPresent: true, | ||
Key: newAcctKey(t), | ||
}, | ||
ExpectedErr: nil, | ||
}, | ||
{ | ||
Name: "Valid contact provided by client ContactsPresent true", | ||
Reg: &corepb.Registration{ | ||
Contact: []string{"mailto:[email protected]"}, | ||
ContactsPresent: true, | ||
Key: newAcctKey(t), | ||
}, | ||
ExpectedErr: nil, | ||
}, | ||
{ | ||
Name: "Valid contact provided by client ContactsPresent false", | ||
Reg: &corepb.Registration{ | ||
Contact: []string{"mailto:[email protected]"}, | ||
ContactsPresent: false, | ||
Key: newAcctKey(t), | ||
}, | ||
ExpectedErr: fmt.Errorf("account contacts present but contactsPresent false"), | ||
}, | ||
} | ||
// For each test case we check that the NewRegistration works as | ||
// intended with variations of Contact and ContactsPresent fields | ||
for _, tc := range testCases { | ||
t.Run(tc.Name, func(t *testing.T) { | ||
// Create new registration | ||
_, err := ra.NewRegistration(ctx, tc.Reg) | ||
// Check error output | ||
if tc.ExpectedErr == nil { | ||
test.AssertNotError(t, err, "expected no error for NewRegistration") | ||
} else { | ||
test.AssertError(t, err, "expected error for NewRegistration") | ||
test.AssertEquals(t, err.Error(), tc.ExpectedErr.Error()) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
type mockSAFailsNewRegistration struct { | ||
sapb.StorageAuthorityClient | ||
} | ||
|