Skip to content

Commit

Permalink
add bad memo test for challenge endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeUrban committed Jan 26, 2023
1 parent 396c454 commit 59b6ae2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions exp/services/webauth/internal/serve/challenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,32 @@ func TestChallengeWithMemo(t *testing.T) {
require.Equal(t, tx.Memo(), memo)
}

func TestChallengeWithBadMemo(t *testing.T) {
serverKey := keypair.MustRandom()
account := keypair.MustRandom()

h := challengeHandler{
Logger: supportlog.DefaultLogger,
NetworkPassphrase: network.TestNetworkPassphrase,
SigningKey: serverKey,
ChallengeExpiresIn: time.Minute,
Domain: "webauthdomain",
HomeDomains: []string{"testdomain"},
}

r := httptest.NewRequest("GET", "/?account="+account.Address()+"&memo=test", nil)
w := httptest.NewRecorder()
h.ServeHTTP(w, r)
resp := w.Result()

require.Equal(t, http.StatusBadRequest, resp.StatusCode)
assert.Equal(t, "application/json; charset=utf-8", resp.Header.Get("Content-Type"))

body, err := ioutil.ReadAll(resp.Body)
require.NoError(t, err)
assert.JSONEq(t, `{"error":"The request was invalid in some way."}`, string(body))
}

func TestChallengeWithMuxedAccount(t *testing.T) {
serverKey := keypair.MustRandom()
account := keypair.MustRandom()
Expand Down

0 comments on commit 59b6ae2

Please sign in to comment.