Skip to content

Commit

Permalink
acme/api: use postAsGet instead of post for AccountService.Get (#1283)
Browse files Browse the repository at this point in the history
Co-authored-by: Fernandez Ludovic <[email protected]>
  • Loading branch information
vancluever and ldez authored Nov 6, 2020
1 parent ff0377a commit 73725b6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion acme/api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (a *AccountService) Get(accountURL string) (acme.Account, error) {
}

var account acme.Account
_, err := a.core.post(accountURL, acme.Account{}, &account)
_, err := a.core.postAsGet(accountURL, &account)
if err != nil {
return acme.Account{}, err
}
Expand Down
32 changes: 32 additions & 0 deletions e2e/challenges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,38 @@ func TestChallengeHTTP_Client_Obtain(t *testing.T) {
assert.Empty(t, resource.CSR)
}

func TestChallengeHTTP_Client_Registration_QueryRegistration(t *testing.T) {
err := os.Setenv("LEGO_CA_CERTIFICATES", "./fixtures/certs/pebble.minica.pem")
require.NoError(t, err)
defer func() { _ = os.Unsetenv("LEGO_CA_CERTIFICATES") }()

privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
require.NoError(t, err, "Could not generate test key")

user := &fakeUser{privateKey: privateKey}
config := lego.NewConfig(user)
config.CADirURL = load.PebbleOptions.HealthCheckURL

client, err := lego.NewClient(config)
require.NoError(t, err)

err = client.Challenge.SetHTTP01Provider(http01.NewProviderServer("", "5002"))
require.NoError(t, err)

reg, err := client.Registration.Register(registration.RegisterOptions{TermsOfServiceAgreed: true})
require.NoError(t, err)
user.registration = reg

resource, err := client.Registration.QueryRegistration()
require.NoError(t, err)

require.NotNil(t, resource)

assert.Equal(t, "valid", resource.Body.Status)
assert.Regexp(t, `https://localhost:14000/list-orderz/\d+`, resource.Body.Orders)
assert.Regexp(t, `https://localhost:14000/my-account/\d+`, resource.URI)
}

func TestChallengeTLS_Client_Obtain(t *testing.T) {
err := os.Setenv("LEGO_CA_CERTIFICATES", "./fixtures/certs/pebble.minica.pem")
require.NoError(t, err)
Expand Down

0 comments on commit 73725b6

Please sign in to comment.