-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removes a bunch of unnecessary tests
- Loading branch information
1 parent
f581384
commit 8f65e8e
Showing
6 changed files
with
122 additions
and
847 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,76 +430,66 @@ func TestEmailDoesExistsWithBadInput(t *testing.T) { | |
res, err := http.DefaultClient.Do(req) | ||
assert.NoError(t, err) | ||
assert.Equal(t, 400, res.StatusCode) | ||
result := *unittesting.HttpResponseToConsumableInformation(res.Body) | ||
assert.Equal(t, "Please provide the email as a GET param", result["message"]) | ||
} | ||
|
||
//email_verify tests | ||
// func TestGenerateTokenAPIWithValidInputAndEmailNotVerified(t *testing.T) { | ||
// customAntiCsrfVal := "VIA_TOKEN" | ||
// configValue := supertokens.TypeInput{ | ||
// Supertokens: &supertokens.ConnectionInfo{ | ||
// ConnectionURI: "http://localhost:8080", | ||
// }, | ||
// AppInfo: supertokens.AppInfo{ | ||
// APIDomain: "api.supertokens.io", | ||
// AppName: "SuperTokens", | ||
// WebsiteDomain: "supertokens.io", | ||
// }, | ||
// RecipeList: []supertokens.Recipe{ | ||
// Init(nil), | ||
// session.Init(&sessmodels.TypeInput{ | ||
// AntiCsrf: &customAntiCsrfVal, | ||
// }), | ||
// }, | ||
// } | ||
|
||
// BeforeEach() | ||
// unittesting.StartUpST("localhost", "8080") | ||
// defer AfterEach() | ||
// err := supertokens.Init(configValue) | ||
// if err != nil { | ||
// t.Error(err.Error()) | ||
// } | ||
// mux := http.NewServeMux() | ||
// testServer := httptest.NewServer(supertokens.Middleware(mux)) | ||
// defer testServer.Close() | ||
|
||
// resp, err := unittesting.SignupRequest("[email protected]", "testPass123", testServer.URL) | ||
// if err != nil { | ||
// t.Error(err.Error()) | ||
// } | ||
// assert.NoError(t, err) | ||
// assert.Equal(t, 200, resp.StatusCode) | ||
// data, _ := io.ReadAll(resp.Body) | ||
// resp.Body.Close() | ||
// var response map[string]interface{} | ||
// _ = json.Unmarshal(data, &response) | ||
// assert.Equal(t, "OK", response["status"]) | ||
|
||
// userId := response["user"].(map[string]interface{})["id"] | ||
// cookieData := unittesting.ExtractInfoFromResponse(resp) | ||
|
||
// verifyToken, err := CreateEmailVerificationToken(userId.(string)) | ||
// if err != nil { | ||
// t.Error(err.Error()) | ||
// } | ||
// VerifyEmailUsingToken(verifyToken.OK.Token) | ||
|
||
// resp1, err := unittesting.EmailVerifyTokenRequest(testServer.URL, userId.(string), cookieData["sAccessToken"], cookieData["antiCsrf"]) | ||
|
||
// if err != nil { | ||
// t.Error(err.Error()) | ||
// } | ||
|
||
// assert.NoError(t, err) | ||
// assert.Equal(t, 200, resp1.StatusCode) | ||
// data1, _ := io.ReadAll(resp1.Body) | ||
// resp1.Body.Close() | ||
// var response1 map[string]interface{} | ||
// _ = json.Unmarshal(data1, &response1) | ||
|
||
// assert.Equal(t, "EMAIL_ALREADY_VERIFIED_ERROR", response1["status"]) | ||
|
||
// } | ||
func TestGenerateTokenAPIWithValidInputAndEmailNotVerified(t *testing.T) { | ||
customCSRFval := "VIA_TOKEN" | ||
configValue := supertokens.TypeInput{ | ||
Supertokens: &supertokens.ConnectionInfo{ | ||
ConnectionURI: "http://localhost:8080", | ||
}, | ||
AppInfo: supertokens.AppInfo{ | ||
APIDomain: "api.supertokens.io", | ||
AppName: "SuperTokens", | ||
WebsiteDomain: "supertokens.io", | ||
}, | ||
RecipeList: []supertokens.Recipe{ | ||
emailverification.Init(evmodels.TypeInput{ | ||
Mode: evmodels.ModeOptional, | ||
}), | ||
Init(nil), | ||
session.Init(&sessmodels.TypeInput{ | ||
AntiCsrf: &customCSRFval, | ||
GetTokenTransferMethod: func(req *http.Request, forCreateNewSession bool, userContext supertokens.UserContext) sessmodels.TokenTransferMethod { | ||
return sessmodels.CookieTransferMethod | ||
}, | ||
}), | ||
}, | ||
} | ||
|
||
BeforeEach() | ||
unittesting.StartUpST("localhost", "8080") | ||
defer AfterEach() | ||
err := supertokens.Init(configValue) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
mux := http.NewServeMux() | ||
testServer := httptest.NewServer(supertokens.Middleware(mux)) | ||
defer testServer.Close() | ||
|
||
resp, err := unittesting.SignupRequest("[email protected]", "validPass123", testServer.URL) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
|
||
cookieData := unittesting.ExtractInfoFromResponse(resp) | ||
|
||
result := *unittesting.HttpResponseToConsumableInformation(resp.Body) | ||
assert.Equal(t, "OK", result["status"]) | ||
user := result["user"].(map[string]interface{}) | ||
|
||
rep1, err := unittesting.EmailVerifyTokenRequest(testServer.URL, user["id"].(string), cookieData["sAccessToken"], cookieData["antiCsrf"]) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
result1 := *unittesting.HttpResponseToConsumableInformation(rep1.Body) | ||
assert.Equal(t, "OK", result1["status"]) | ||
} | ||
|
||
func TestGenerateTokenAPIWithValidInputNoSessionAndCheckOutput(t *testing.T) { | ||
customAntiCsrfVal := "VIA_TOKEN" | ||
|
@@ -558,6 +548,69 @@ func TestGenerateTokenAPIWithValidInputNoSessionAndCheckOutput(t *testing.T) { | |
assert.Equal(t, "unauthorised", response["message"]) | ||
} | ||
|
||
func TestGenerateTokenAPIwithValidInputEmailVerifiedAndTestError(t *testing.T) { | ||
customCSRFval := "VIA_TOKEN" | ||
configValue := supertokens.TypeInput{ | ||
Supertokens: &supertokens.ConnectionInfo{ | ||
ConnectionURI: "http://localhost:8080", | ||
}, | ||
AppInfo: supertokens.AppInfo{ | ||
APIDomain: "api.supertokens.io", | ||
AppName: "SuperTokens", | ||
WebsiteDomain: "supertokens.io", | ||
}, | ||
RecipeList: []supertokens.Recipe{ | ||
emailverification.Init(evmodels.TypeInput{ | ||
Mode: evmodels.ModeOptional, | ||
}), | ||
Init(nil), | ||
session.Init(&sessmodels.TypeInput{ | ||
AntiCsrf: &customCSRFval, | ||
GetTokenTransferMethod: func(req *http.Request, forCreateNewSession bool, userContext supertokens.UserContext) sessmodels.TokenTransferMethod { | ||
return sessmodels.CookieTransferMethod | ||
}, | ||
}), | ||
}, | ||
} | ||
|
||
BeforeEach() | ||
unittesting.StartUpST("localhost", "8080") | ||
defer AfterEach() | ||
err := supertokens.Init(configValue) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
mux := http.NewServeMux() | ||
testServer := httptest.NewServer(supertokens.Middleware(mux)) | ||
defer testServer.Close() | ||
|
||
resp, err := unittesting.SignupRequest("[email protected]", "validPass123", testServer.URL) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
|
||
cookieData := unittesting.ExtractInfoFromResponse(resp) | ||
|
||
result := *unittesting.HttpResponseToConsumableInformation(resp.Body) | ||
assert.Equal(t, "OK", result["status"]) | ||
user := result["user"].(map[string]interface{}) | ||
|
||
verifyToken, err := emailverification.CreateEmailVerificationToken("public", user["id"].(string), nil) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
emailverification.VerifyEmailUsingToken("public", verifyToken.OK.Token) | ||
|
||
rep1, err := unittesting.EmailVerifyTokenRequest(testServer.URL, user["id"].(string), cookieData["sAccessToken"], cookieData["antiCsrf"]) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
result1 := *unittesting.HttpResponseToConsumableInformation(rep1.Body) | ||
assert.Equal(t, "EMAIL_ALREADY_VERIFIED_ERROR", result1["status"]) | ||
} | ||
|
||
func TestGenerateTokenAPIWithExpiredAccessToken(t *testing.T) { | ||
customAntiCsrfVal := "VIA_TOKEN" | ||
configValue := supertokens.TypeInput{ | ||
|
2 changes: 1 addition & 1 deletion
2
...rdpartyemailpassword/loginmethods_test.go → recipe/emailpassword/loginmethods_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package thirdpartyemailpassword | ||
package emailpassword | ||
|
||
import ( | ||
"encoding/json" | ||
|
164 changes: 0 additions & 164 deletions
164
recipe/thirdpartyemailpassword/authorisationUrlFeature_test.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.