| 128 | } |
| 129 | |
| 130 | func 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 | |
| 147 | func MockSessionCreateHandlerWithIdentityAndAMR(t *testing.T, reg mockDeps, i *identity.Identity, methods []identity.CredentialsType) (http.HandlerFunc, *session.Session) { |
| 148 | var sess session.Session |