Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions cmd/otpgateway/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,14 @@ func TestCheckOTP(t *testing.T) {

// Check it again. Should be deleted.
r = testRequest(t, http.MethodPost, "/api/otp/"+dummyOTPID, cp, &data)
assert.NotEqual(t, http.StatusOK, r.StatusCode, "OTP didn't get deleted on verification")
assert.Equal(t, http.StatusGone, r.StatusCode, "OTP didn't get deleted on verification")

// Check non-existent OTP, should not return 200.
// Check non-existent OTP, should return 410 Gone.
r = testRequest(t, http.MethodPost, "/api/otp/abc123", cp, &data)
assert.NotEqual(t, http.StatusOK, r.StatusCode, "non-existent OTP didn't return 200")
assert.Equal(t, http.StatusGone, r.StatusCode, "non-existent OTP didn't return 410")

// Check non-existent OTP, should return 410.
r = testRequest(t, http.MethodPost, "/api/otp/abc123", cp, &out)
assert.Equal(t, http.StatusGone, r.StatusCode, "non-existent OTP returns 410")
// Check non-existent OTP, should return store.ErrNotExist error message.
_ = testRequest(t, http.MethodPost, "/api/otp/abc123", cp, &out)
assert.Equal(t, "OTP has expired or doesn't exist", out.Message, "non-existent OTP passed")
}

Expand Down
Loading