func TestValidateRequestError(t *testing.T) { testhelper.SetupHTTP() defer testhelper.TeardownHTTP() client := prepareAuthTokenHandler(t, "HEAD", http.StatusUnauthorized) _, err := tokens.Validate(&client, "abcdef12345") if err == nil { t.Errorf("Missing expected error from Validate") } }
func TestValidateRequestFailure(t *testing.T) { testhelper.SetupHTTP() defer testhelper.TeardownHTTP() client := prepareAuthTokenHandler(t, "HEAD", http.StatusNotFound) ok, err := tokens.Validate(&client, "abcdef12345") if err != nil { t.Errorf("Unexpected error from Validate: %v", err) } if ok { t.Errorf("Validate returned true for an invalid token") } }
func TestValidateRequestSuccessful(t *testing.T) { testhelper.SetupHTTP() defer testhelper.TeardownHTTP() client := prepareAuthTokenHandler(t, "HEAD", http.StatusNoContent) ok, err := tokens.Validate(&client, "abcdef12345") if err != nil { t.Errorf("Unexpected error from Validate: %v", err) } if !ok { t.Errorf("Validate returned false for a valid token") } }