acme: preserve account URI on get and update
Let's Encrypt has always provided Account URI in a response to any registration request (new, get and update) in the Location header, up until recently (?). Today, LE's servers provide Account URI only for new-reg requests. In fact, the spec does not say anything about Account URI and Location header for "get" and "update" requests. This change preserves Account URI in return values for "get" and "update" requests, which is already provided by the caller anyway. Change-Id: I8b1112d7443935715e9184a511b5e30a27008e8c Reviewed-on: https://go-review.googlesource.com/26931 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
@@ -229,14 +229,24 @@ func (c *Client) Register(a *Account, prompt func(tos string) bool) (*Account, e
|
||||
// GetReg retrieves an existing registration.
|
||||
// The url argument is an Account URI.
|
||||
func (c *Client) GetReg(url string) (*Account, error) {
|
||||
a := &Account{URI: url}
|
||||
return c.doReg(url, "reg", a)
|
||||
a, err := c.doReg(url, "reg", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.URI = url
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// UpdateReg updates an existing registration.
|
||||
// It returns an updated account copy. The provided account is not modified.
|
||||
func (c *Client) UpdateReg(a *Account) (*Account, error) {
|
||||
return c.doReg(a.URI, "reg", a)
|
||||
uri := a.URI
|
||||
a, err := c.doReg(uri, "reg", a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.URI = uri
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// Authorize performs the initial step in an authorization flow.
|
||||
|
||||
@@ -205,6 +205,9 @@ func TestUpdateReg(t *testing.T) {
|
||||
if a.CurrentTerms != terms {
|
||||
t.Errorf("a.CurrentTerms = %q; want %q", a.CurrentTerms, terms)
|
||||
}
|
||||
if a.URI != ts.URL {
|
||||
t.Errorf("a.URI = %q; want %q", a.URI, ts.URL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetReg(t *testing.T) {
|
||||
@@ -266,6 +269,9 @@ func TestGetReg(t *testing.T) {
|
||||
if a.CurrentTerms != newTerms {
|
||||
t.Errorf("a.CurrentTerms = %q; want %q", a.CurrentTerms, newTerms)
|
||||
}
|
||||
if a.URI != ts.URL {
|
||||
t.Errorf("a.URI = %q; want %q", a.URI, ts.URL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthorize(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user