forked from TrueCloudLab/lego
Registrar.ResolveAccountByKey: Fix issues found testing with Pebble (#1142)
This commit is contained in:
parent
e5d4dd166d
commit
0714fcf679
2 changed files with 3 additions and 15 deletions
|
@ -156,15 +156,10 @@ func (r *Registrar) ResolveAccountByKey() (*Resource, error) {
|
||||||
log.Infof("acme: Trying to resolve account by key")
|
log.Infof("acme: Trying to resolve account by key")
|
||||||
|
|
||||||
accMsg := acme.Account{OnlyReturnExisting: true}
|
accMsg := acme.Account{OnlyReturnExisting: true}
|
||||||
accountTransit, err := r.core.Accounts.New(accMsg)
|
account, err := r.core.Accounts.New(accMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
account, err := r.core.Accounts.Get(accountTransit.Location)
|
return &Resource{URI: account.Location, Body: account.Account}, nil
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Resource{URI: accountTransit.Location, Body: account}, nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,7 @@ func TestRegistrar_ResolveAccountByKey(t *testing.T) {
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/account", func(w http.ResponseWriter, _ *http.Request) {
|
mux.HandleFunc("/account", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Location", apiURL+"/account_recovery")
|
w.Header().Set("Location", apiURL+"/account")
|
||||||
_, err := w.Write([]byte("{}"))
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.HandleFunc("/account_recovery", func(w http.ResponseWriter, _ *http.Request) {
|
|
||||||
err := tester.WriteJSONResponse(w, acme.Account{
|
err := tester.WriteJSONResponse(w, acme.Account{
|
||||||
Status: "valid",
|
Status: "valid",
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue