Registrar.ResolveAccountByKey: Fix issues found testing with Pebble (#1142)

This commit is contained in:
Anders Chen 2020-05-26 13:06:38 -04:00 committed by GitHub
parent e5d4dd166d
commit 0714fcf679
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 15 deletions

View file

@ -156,15 +156,10 @@ func (r *Registrar) ResolveAccountByKey() (*Resource, error) {
log.Infof("acme: Trying to resolve account by key")
accMsg := acme.Account{OnlyReturnExisting: true}
accountTransit, err := r.core.Accounts.New(accMsg)
account, err := r.core.Accounts.New(accMsg)
if err != nil {
return nil, err
}
account, err := r.core.Accounts.Get(accountTransit.Location)
if err != nil {
return nil, err
}
return &Resource{URI: accountTransit.Location, Body: account}, nil
return &Resource{URI: account.Location, Body: account.Account}, nil
}

View file

@ -18,14 +18,7 @@ func TestRegistrar_ResolveAccountByKey(t *testing.T) {
defer tearDown()
mux.HandleFunc("/account", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Location", apiURL+"/account_recovery")
_, err := w.Write([]byte("{}"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
})
mux.HandleFunc("/account_recovery", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Location", apiURL+"/account")
err := tester.WriteJSONResponse(w, acme.Account{
Status: "valid",
})