-
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.
- Loading branch information
1 parent
cb383a9
commit c079e94
Showing
21 changed files
with
1,019 additions
and
33 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
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
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
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 |
---|---|---|
|
@@ -32,10 +32,117 @@ import ( | |
"github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" | ||
"github.com/supertokens/supertokens-golang/recipe/session" | ||
"github.com/supertokens/supertokens-golang/recipe/session/sessmodels" | ||
"github.com/supertokens/supertokens-golang/recipe/thirdparty" | ||
"github.com/supertokens/supertokens-golang/recipe/thirdparty/tpmodels" | ||
"github.com/supertokens/supertokens-golang/supertokens" | ||
"github.com/supertokens/supertokens-golang/test/unittesting" | ||
) | ||
|
||
func TestRightRidButRecipeMissingReturns404(t *testing.T) { | ||
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{ | ||
thirdparty.Init(&tpmodels.TypeInput{ | ||
SignInAndUpFeature: tpmodels.TypeInputSignInAndUp{ | ||
Providers: []tpmodels.ProviderInput{ | ||
{ | ||
Config: tpmodels.ProviderConfig{ | ||
ThirdPartyId: "google", | ||
Clients: []tpmodels.ProviderClientConfig{ | ||
{ | ||
ClientID: "4398792-test-id", | ||
ClientSecret: "test-secret", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}), | ||
}, | ||
} | ||
|
||
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() | ||
|
||
res, err := unittesting.SignInRequest("[email protected]", "validpass123", testServer.URL) | ||
|
||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
assert.NoError(t, err) | ||
assert.Equal(t, 404, res.StatusCode) | ||
} | ||
|
||
func TestSignInWorksWithThirdPartyEmailPasswordRid(t *testing.T) { | ||
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{ | ||
thirdparty.Init(&tpmodels.TypeInput{ | ||
SignInAndUpFeature: tpmodels.TypeInputSignInAndUp{ | ||
Providers: []tpmodels.ProviderInput{ | ||
{ | ||
Config: tpmodels.ProviderConfig{ | ||
ThirdPartyId: "google", | ||
Clients: []tpmodels.ProviderClientConfig{ | ||
{ | ||
ClientID: "4398792-test-id", | ||
ClientSecret: "test-secret", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}), | ||
Init(nil), | ||
}, | ||
} | ||
|
||
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() | ||
|
||
res, err := unittesting.SignInRequestWithThirdpartyemailpasswordRid("[email protected]", "validpass123", testServer.URL) | ||
|
||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
assert.NoError(t, err) | ||
assert.Equal(t, 200, res.StatusCode) | ||
} | ||
|
||
// SigninFeature Tests | ||
func TestDisablingAPIDefaultSigninDoesNotWork(t *testing.T) { | ||
configValue := supertokens.TypeInput{ | ||
|
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
Oops, something went wrong.