MCPcopy
hub / github.com/ory/kratos / MockSessionCreateHandlerWithIdentity

Function MockSessionCreateHandlerWithIdentity

pkg/testhelpers/handler_mock.go:130–145  ·  view source on GitHub ↗
(t *testing.T, reg mockDeps, i *identity.Identity)

Source from the content-addressed store, hash-verified

128}
129
130func MockSessionCreateHandlerWithIdentity(t *testing.T, reg mockDeps, i *identity.Identity) (http.HandlerFunc, *session.Session) {
131 var ct []identity.CredentialsType
132
133 // if identity was not created with any credentials,
134 // then assume a 'password' credential type
135 if len(i.Credentials) == 0 {
136 return MockSessionCreateHandlerWithIdentityAndAMR(t, reg, i, []identity.CredentialsType{"password"})
137 }
138
139 // otherwise, mock session with appropriate credential types
140 for _, c := range i.Credentials {
141 ct = append(ct, c.Type)
142 }
143
144 return MockSessionCreateHandlerWithIdentityAndAMR(t, reg, i, ct)
145}
146
147func MockSessionCreateHandlerWithIdentityAndAMR(t *testing.T, reg mockDeps, i *identity.Identity, methods []identity.CredentialsType) (http.HandlerFunc, *session.Session) {
148 var sess session.Session

Callers 4

TestSessionWhoAmIFunction · 0.92
MockSessionCreateHandlerFunction · 0.85
AddAndLoginIdentitiesFunction · 0.85

Tested by 2

TestSessionWhoAmIFunction · 0.74