Skip to content

Commit 3d63e3e

Browse files
authored
Ensure we return a location during account updates (#1158)
1 parent 0714fcf commit 3d63e3e

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

acme/api/account.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ func (a *AccountService) Get(accountURL string) (acme.Account, error) {
5858
}
5959

6060
// Update Updates an account.
61-
func (a *AccountService) Update(accountURL string, req acme.Account) (acme.ExtendedAccount, error) {
61+
func (a *AccountService) Update(accountURL string, req acme.Account) (acme.Account, error) {
6262
if len(accountURL) == 0 {
63-
return acme.ExtendedAccount{}, errors.New("account[update]: empty URL")
63+
return acme.Account{}, errors.New("account[update]: empty URL")
6464
}
6565

66-
var account acme.ExtendedAccount
66+
var account acme.Account
6767
_, err := a.core.post(accountURL, req, &account)
6868
if err != nil {
69-
return acme.ExtendedAccount{}, err
69+
return acme.Account{}, err
7070
}
71+
7172
return account, nil
7273
}
7374

e2e/challenges_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,14 @@ func TestRegistrar_UpdateAccount(t *testing.T) {
340340
regOptions := registration.RegisterOptions{TermsOfServiceAgreed: true}
341341
reg, err := client.Registration.Register(regOptions)
342342
require.NoError(t, err)
343-
require.Equal(t, reg.Body.Contact, []string{"mailto:[email protected]"})
343+
require.Equal(t, []string{"mailto:[email protected]"}, reg.Body.Contact)
344344
user.registration = reg
345345

346346
user.email = "[email protected]"
347347
resource, err := client.Registration.UpdateRegistration(regOptions)
348348
require.NoError(t, err)
349-
require.Equal(t, resource.Body.Contact, []string{"mailto:[email protected]"})
350-
require.Empty(t, resource.URI)
349+
require.Equal(t, []string{"mailto:[email protected]"}, resource.Body.Contact)
350+
require.Equal(t, reg.URI, resource.URI)
351351
}
352352

353353
type fakeUser struct {

registration/registar.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,14 @@ func (r *Registrar) UpdateRegistration(options RegisterOptions) (*Resource, erro
131131
accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
132132
}
133133

134-
account, err := r.core.Accounts.Update(r.user.GetRegistration().URI, accMsg)
134+
accountURL := r.user.GetRegistration().URI
135+
136+
account, err := r.core.Accounts.Update(accountURL, accMsg)
135137
if err != nil {
136138
return nil, err
137139
}
138140

139-
return &Resource{URI: account.Location, Body: account.Account}, nil
141+
return &Resource{URI: accountURL, Body: account}, nil
140142
}
141143

142144
// DeleteRegistration deletes the client's user registration from the ACME server.

0 commit comments

Comments
 (0)