forked from letsencrypt/boulder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bad error return in RA (letsencrypt#3061)
RA.NewRegistration checked for an error return from SA.NewRegistration, but failed to properly propagate the error. It was just setting the err variable and falling through to the successful return case. This fixes that issue and adds a unittest.
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,6 +394,30 @@ func TestNewRegistration(t *testing.T) { | |
test.Assert(t, core.KeyDigestEquals(reg.Key, AccountKeyB), "Retrieved registration differed.") | ||
} | ||
|
||
type mockSAFailsNewRegistration struct { | ||
mocks.StorageAuthority | ||
} | ||
|
||
func (ms *mockSAFailsNewRegistration) NewRegistration(ctx context.Context, reg core.Registration) (core.Registration, error) { | ||
return core.Registration{}, fmt.Errorf("too bad") | ||
} | ||
|
||
func TestNewRegistrationSAFailure(t *testing.T) { | ||
_, _, ra, _, cleanUp := initAuthorities(t) | ||
defer cleanUp() | ||
ra.SA = &mockSAFailsNewRegistration{} | ||
input := core.Registration{ | ||
Contact: &[]string{"mailto:[email protected]"}, | ||
Key: &AccountKeyB, | ||
InitialIP: net.ParseIP("7.6.6.5"), | ||
} | ||
|
||
result, err := ra.NewRegistration(ctx, input) | ||
if err == nil { | ||
t.Fatalf("NewRegistration should have failed when SA.NewRegistration failed %#v", result.Key) | ||
} | ||
} | ||
|
||
func TestNewRegistrationNoFieldOverwrite(t *testing.T) { | ||
_, _, ra, _, cleanUp := initAuthorities(t) | ||
defer cleanUp() | ||
|