-
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.
Merge pull request #404 from supertokens/remove-combination-recipe/ro…
…uting-change makes change to middleware routing logic
- Loading branch information
Showing
22 changed files
with
1,095 additions
and
77 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.