(t1, t2 Storage)
| 192 | } |
| 193 | |
| 194 | func TestHelperCreateGetUpdateDeleteClient(t1, t2 Storage) func(t *testing.T) { |
| 195 | return func(t *testing.T) { |
| 196 | ctx := context.Background() |
| 197 | _, err := t1.GetClient(ctx, "1234") |
| 198 | require.Error(t, err) |
| 199 | |
| 200 | t1c1 := &Client{ |
| 201 | ID: uuidx.NewV4().String(), |
| 202 | Name: "name", |
| 203 | Secret: "secret", |
| 204 | RedirectURIs: []string{"http://redirect", "http://redirect1"}, |
| 205 | GrantTypes: []string{"implicit", "refresh_token"}, |
| 206 | ResponseTypes: []string{"code token", "token id_token", "code"}, |
| 207 | Scope: "scope-a scope-b", |
| 208 | Owner: "aeneas", |
| 209 | PolicyURI: "http://policy", |
| 210 | TermsOfServiceURI: "http://tos", |
| 211 | ClientURI: "http://client", |
| 212 | LogoURI: "http://logo", |
| 213 | Contacts: []string{"aeneas1", "aeneas2"}, |
| 214 | SecretExpiresAt: 0, |
| 215 | SectorIdentifierURI: "https://sector", |
| 216 | JSONWebKeys: &x.JoseJSONWebKeySet{JSONWebKeySet: &jose.JSONWebKeySet{Keys: []jose.JSONWebKey{{KeyID: "foo", Key: []byte("asdf"), Certificates: []*x509.Certificate{}, CertificateThumbprintSHA1: []uint8{}, CertificateThumbprintSHA256: []uint8{}}}}}, |
| 217 | JSONWebKeysURI: "https://...", |
| 218 | TokenEndpointAuthMethod: "none", |
| 219 | TokenEndpointAuthSigningAlgorithm: "RS256", |
| 220 | RequestURIs: []string{"foo", "bar"}, |
| 221 | AllowedCORSOrigins: []string{"foo", "bar"}, |
| 222 | RequestObjectSigningAlgorithm: "rs256", |
| 223 | UserinfoSignedResponseAlg: "RS256", |
| 224 | CreatedAt: time.Now().Add(-time.Hour).Round(time.Second).UTC(), |
| 225 | UpdatedAt: time.Now().Add(-time.Minute).Round(time.Second).UTC(), |
| 226 | FrontChannelLogoutURI: "http://fc-logout", |
| 227 | FrontChannelLogoutSessionRequired: true, |
| 228 | PostLogoutRedirectURIs: []string{"hello", "mister"}, |
| 229 | BackChannelLogoutURI: "http://bc-logout", |
| 230 | BackChannelLogoutSessionRequired: true, |
| 231 | } |
| 232 | |
| 233 | require.NoError(t, t1.CreateClient(ctx, t1c1)) |
| 234 | assert.NotEmpty(t, t1c1.GetHashedSecret()) |
| 235 | |
| 236 | t2c1 := *t1c1 |
| 237 | require.NoError(t, t2.CreateClient(ctx, &t2c1), "we should be able to create a client with the same ID in other network") |
| 238 | |
| 239 | t2c3 := *t1c1 |
| 240 | { |
| 241 | t2c3.ID = uuidx.NewV4().String() |
| 242 | require.NoError(t, t2.CreateClient(ctx, &t2c3)) |
| 243 | require.ErrorIs(t, t2.CreateClient(ctx, &t2c3), sqlcon.ErrUniqueViolation) |
| 244 | } |
| 245 | |
| 246 | c2Template := &Client{ |
| 247 | ID: uuidx.NewV4().String(), |
| 248 | Name: "name2", |
| 249 | Secret: "secret", |
| 250 | RedirectURIs: []string{"http://redirect"}, |
| 251 | TermsOfServiceURI: "foo", |
no test coverage detected