-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersister_test.go
63 lines (46 loc) · 1.8 KB
/
persister_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package sql_test
import (
"testing"
"time"
"github.com/pborman/uuid"
"github.com/stretchr/testify/require"
"github.com/ory/hydra/jwk"
"github.com/ory/hydra/client"
"github.com/ory/hydra/consent"
"github.com/ory/hydra/driver"
"github.com/ory/hydra/driver/config"
"github.com/ory/hydra/internal"
)
func TestManagers(t *testing.T) {
conf := internal.NewConfigurationWithDefaults()
conf.MustSet(config.KeyAccessTokenLifespan, time.Hour)
registries := map[string]driver.Registry{
"memory": internal.NewRegistryMemory(t, conf),
}
if !testing.Short() {
registries["postgres"], registries["mysql"], registries["cockroach"], _ = internal.ConnectDatabases(t)
}
for k, m := range registries {
t.Run("package=client/manager="+k, func(t *testing.T) {
t.Run("case=create-get-update-delete", client.TestHelperCreateGetUpdateDeleteClient(k, m.ClientManager()))
t.Run("case=autogenerate-key", client.TestHelperClientAutoGenerateKey(k, m.ClientManager()))
t.Run("case=auth-client", client.TestHelperClientAuthenticate(k, m.ClientManager()))
t.Run("case=update-two-clients", client.TestHelperUpdateTwoClients(k, m.ClientManager()))
})
t.Run("package=consent/manager="+k, consent.ManagerTests(m.ConsentManager(), m.ClientManager(), m.OAuth2Storage()))
t.Run("package=jwk/manager="+k, func(t *testing.T) {
var testGenerator = &jwk.RS256Generator{}
t.Run("TestManagerKey", func(t *testing.T) {
ks, err := testGenerator.Generate("TestManagerKey", "sig")
require.NoError(t, err)
jwk.TestHelperManagerKey(m.KeyManager(), ks, uuid.New())
})
t.Run("TestManagerKeySet", func(t *testing.T) {
ks, err := testGenerator.Generate("TestManagerKeySet", "sig")
require.NoError(t, err)
ks.Key("private")
jwk.TestHelperManagerKeySet(m.KeyManager(), ks, uuid.New())
})
})
}
}