diff --git a/tests/integration/clerk_test.go b/tests/integration/clerk_test.go index 43f4bb1..3f1d025 100644 --- a/tests/integration/clerk_test.go +++ b/tests/integration/clerk_test.go @@ -10,10 +10,8 @@ import ( type key string const ( - APIUrl = "CLERK_API_URL" - APIKey = "CLERK_API_KEY" - SessionToken = "CLERK_SESSION_TOKEN" - SessionID = "CLERK_SESSION_ID" + APIUrl = "CLERK_API_URL" + APIKey = "CLERK_API_KEY" ) func createClient() clerk.Client { diff --git a/tests/integration/verification_test.go b/tests/integration/verification_test.go deleted file mode 100644 index 7e14859..0000000 --- a/tests/integration/verification_test.go +++ /dev/null @@ -1,89 +0,0 @@ -// +build integration - -package integration - -import ( - "github.com/clerkinc/clerk-sdk-go/clerk" - "net/http" - "net/url" - "testing" -) - -func TestVerification_clientActiveSession(t *testing.T) { - client := createClient() - - request := buildRequest(nil) - - session, err := client.Verification().Verify(request) - if err != nil { - t.Errorf("Was not expecting error, found %v instead", err) - } - - if session == nil { - t.Errorf("Was expecting session to be returned") - } -} - -func TestVerification_verifySessionId(t *testing.T) { - client := createClient() - - sessionId := getEnv(SessionID) - request := buildRequest(&sessionId) - - session, err := client.Verification().Verify(request) - if err != nil { - t.Errorf("Was not expecting error, found %v instead", err) - } - - if session == nil { - t.Errorf("Was expecting session to be returned") - } -} - -func TestVerification_returnsClerkErrorForInvalidSessionID(t *testing.T) { - client := createClientWithKey(getEnv(APIUrl), "invalid_key") - - request := buildRequest(nil) - - session, err := client.Verification().Verify(request) - if err == nil { - t.Fatal("Was expecting error") - } - - if session != nil { - t.Fatalf("Was not expecting session to be returned, found %v instead", session) - } - - if _, isClerkErr := err.(*clerk.ErrorResponse); !isClerkErr { - t.Fatalf("Was expecting a Clerk error response, got %v instead", err) - } -} - -func buildRequest(sessionId *string) *http.Request { - var request http.Request - request.Method = "GET" - - url := url.URL{ - Scheme: "http", - Host: "host.com", - Path: "path", - } - request.URL = &url - - // add session token as cookie - sessionCookie := http.Cookie{ - Name: clerk.CookieSession, - Value: getEnv(SessionToken), - } - request.Header = make(map[string][]string) - request.AddCookie(&sessionCookie) - - if sessionId != nil { - // add session id as query parameter - query := url.Query() - query.Add(clerk.QueryParamSessionId, *sessionId) - url.RawQuery = query.Encode() - } - - return &request -}