Skip to content

Commit

Permalink
test: use different return handler
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent 3bdb8ab commit e489a43
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
2 changes: 1 addition & 1 deletion selfservice/strategy/password/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestCompleteLogin(t *testing.T) {

errTS := testhelpers.NewErrorTestServer(t, reg)
uiTS := testhelpers.NewLoginUIFlowEchoServer(t, reg)
redirTS := newReturnTs(t, reg)
redirTS := testhelpers.NewRedirSessionEchoTS(t, reg)

// Overwrite these two:
conf.MustSet(config.ViperKeySelfServiceErrorUI, errTS.URL+"/error-ts")
Expand Down
19 changes: 0 additions & 19 deletions selfservice/strategy/password/strategy_disabled_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package password_test

import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"testing"

Expand All @@ -16,25 +14,8 @@ import (
"github.com/ory/kratos/driver/config"
"github.com/ory/kratos/identity"
"github.com/ory/kratos/internal"
"github.com/ory/kratos/session"
"github.com/ory/kratos/x"
)

func newReturnTs(t *testing.T, reg interface {
session.ManagementProvider
x.WriterProvider
config.Provider
}) *httptest.Server {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
sess, err := reg.SessionManager().FetchFromRequest(r.Context(), r)
require.NoError(t, err)
reg.Writer().Write(w, r, sess)
}))
t.Cleanup(ts.Close)
reg.Config(context.Background()).MustSet(config.ViperKeySelfServiceBrowserDefaultReturnTo, ts.URL+"/return-ts")
return ts
}

func TestDisabledEndpoint(t *testing.T) {
conf, reg := internal.NewFastRegistryWithMocks(t)
testhelpers.StrategyEnable(t, conf, identity.CredentialsTypePassword.String(), false)
Expand Down

0 comments on commit e489a43

Please sign in to comment.