Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored and hperl committed Apr 5, 2023
1 parent 28148d3 commit d51ba70
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions internal/testhelpers/selfservice_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func SubmitLoginForm(
expectedURL string,
opts ...InitFlowWithOption,
) string {
t.Helper()
if hc == nil {
hc = new(http.Client)
if !isAPI {
Expand Down
5 changes: 3 additions & 2 deletions internal/testhelpers/selfservice_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ func InitializeRegistrationFlowViaBrowser(t *testing.T, client *http.Client, ts
flowID = gjson.GetBytes(body, "id").String()
}

rs, _, err := NewSDKCustomClient(ts, client).FrontendApi.GetRegistrationFlow(context.Background()).Id(flowID).Execute()
rs, res, err := NewSDKCustomClient(ts, client).FrontendApi.GetRegistrationFlow(context.Background()).Id(flowID).Execute()
if expectGetError {
require.Error(t, err)
require.Nil(t, rs)
} else {
require.NoError(t, err)
require.NoError(t, err, "%#v", string(ioutilx.MustReadAll(res.Body)))
assert.Empty(t, rs.Active)
}
return rs
Expand Down Expand Up @@ -119,6 +119,7 @@ func SubmitRegistrationForm(
expectedURL string,
opts ...InitFlowWithOption,
) string {
t.Helper()
if hc == nil {
hc = new(http.Client)
}
Expand Down
19 changes: 15 additions & 4 deletions selfservice/strategy/oidc/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import (
"testing"
"time"

"github.com/ory/x/sqlxx"

"github.com/ory/x/snapshotx"
"github.com/ory/x/sqlxx"

"github.com/ory/kratos/text"

Expand Down Expand Up @@ -233,6 +232,12 @@ func TestStrategy(t *testing.T) {
var newRegistrationFlowBrowser = func(t *testing.T, redirectTo string, exp time.Duration) *registration.Flow {
return newRegistrationFlow(t, redirectTo, exp, flow.TypeBrowser)
}
// _ = assertSystemError
// _ = asem
// _ = ai
// _ = newLoginFlowBrowser
// _ = registerAction
// _ = loginAction

t.Run("case=should fail because provider does not exist", func(t *testing.T) {
for k, v := range []string{
Expand Down Expand Up @@ -687,11 +692,14 @@ func TestStrategy(t *testing.T) {

t.Run("case=webview", func(t *testing.T) {
body := testhelpers.SubmitRegistrationForm(t, false, webViewHTTPClient, ts, values,
false, http.StatusFound, ts.URL+"/self-service/methods/oidc/callback/valid",
false, http.StatusOK, uiTS.URL,
testhelpers.InitFlowWithReturnTo(webviewRedirectURI))

assert.Empty(t, gjson.Get(body, "session_token"), "%s", body)
assert.Empty(t, gjson.Get(body, "session"), "%s", body)
assert.Len(t, gjson.Get(body, "ui.messages").Array(), 1, "%s", body)
assert.EqualValues(t, gjson.Get(body, "ui.messages.0.id").Int(), text.ErrorValidationDuplicateCredentialsOnOIDCLink, "%s", body)
assert.Contains(t, gjson.Get(body, "ui.messages.0.text").String(), "An account with the same identifier", "%s", body)
})
})

Expand All @@ -705,11 +713,14 @@ func TestStrategy(t *testing.T) {

t.Run("case=webview", func(t *testing.T) {
body := testhelpers.SubmitLoginForm(t, false, webViewHTTPClient, ts, values,
false, false, http.StatusFound, ts.URL+"/self-service/methods/oidc/callback/valid",
false, false, http.StatusOK, uiTS.URL,
testhelpers.InitFlowWithReturnTo(webviewRedirectURI))

assert.Empty(t, gjson.Get(body, "session_token"), "%s", body)
assert.Empty(t, gjson.Get(body, "session"), "%s", body)
assert.Len(t, gjson.Get(body, "ui.messages").Array(), 1, "%s", body)
assert.EqualValues(t, gjson.Get(body, "ui.messages.0.id").Int(), text.ErrorValidationDuplicateCredentialsOnOIDCLink, "%s", body)
assert.Contains(t, gjson.Get(body, "ui.messages.0.text").String(), "An account with the same identifier", "%s", body)
})
})
})
Expand Down

0 comments on commit d51ba70

Please sign in to comment.