forked from TrueCloudLab/lego
Ensure we return a location during account updates (#1158)
This commit is contained in:
parent
0714fcf679
commit
3d63e3ec07
3 changed files with 12 additions and 9 deletions
|
@ -58,16 +58,17 @@ func (a *AccountService) Get(accountURL string) (acme.Account, error) {
|
|||
}
|
||||
|
||||
// Update Updates an account.
|
||||
func (a *AccountService) Update(accountURL string, req acme.Account) (acme.ExtendedAccount, error) {
|
||||
func (a *AccountService) Update(accountURL string, req acme.Account) (acme.Account, error) {
|
||||
if len(accountURL) == 0 {
|
||||
return acme.ExtendedAccount{}, errors.New("account[update]: empty URL")
|
||||
return acme.Account{}, errors.New("account[update]: empty URL")
|
||||
}
|
||||
|
||||
var account acme.ExtendedAccount
|
||||
var account acme.Account
|
||||
_, err := a.core.post(accountURL, req, &account)
|
||||
if err != nil {
|
||||
return acme.ExtendedAccount{}, err
|
||||
return acme.Account{}, err
|
||||
}
|
||||
|
||||
return account, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -340,14 +340,14 @@ func TestRegistrar_UpdateAccount(t *testing.T) {
|
|||
regOptions := registration.RegisterOptions{TermsOfServiceAgreed: true}
|
||||
reg, err := client.Registration.Register(regOptions)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, reg.Body.Contact, []string{"mailto:foo@example.com"})
|
||||
require.Equal(t, []string{"mailto:foo@example.com"}, reg.Body.Contact)
|
||||
user.registration = reg
|
||||
|
||||
user.email = "bar@example.com"
|
||||
resource, err := client.Registration.UpdateRegistration(regOptions)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, resource.Body.Contact, []string{"mailto:bar@example.com"})
|
||||
require.Empty(t, resource.URI)
|
||||
require.Equal(t, []string{"mailto:bar@example.com"}, resource.Body.Contact)
|
||||
require.Equal(t, reg.URI, resource.URI)
|
||||
}
|
||||
|
||||
type fakeUser struct {
|
||||
|
|
|
@ -131,12 +131,14 @@ func (r *Registrar) UpdateRegistration(options RegisterOptions) (*Resource, erro
|
|||
accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
|
||||
}
|
||||
|
||||
account, err := r.core.Accounts.Update(r.user.GetRegistration().URI, accMsg)
|
||||
accountURL := r.user.GetRegistration().URI
|
||||
|
||||
account, err := r.core.Accounts.Update(accountURL, accMsg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Resource{URI: account.Location, Body: account.Account}, nil
|
||||
return &Resource{URI: accountURL, Body: account}, nil
|
||||
}
|
||||
|
||||
// DeleteRegistration deletes the client's user registration from the ACME server.
|
||||
|
|
Loading…
Reference in a new issue