Skip to content

Commit a521bf0

Browse files
osmianMike Osmian
and
Mike Osmian
authored
initial (Nerzal#412)
Co-authored-by: Mike Osmian <[email protected]>
1 parent 6421072 commit a521bf0

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
test:
22
./run-tests.sh
33

4-
start-keycloak:
4+
start-keycloak: stop-keycloak
5+
docker-compose up -d
6+
7+
stop-keycloak:
58
docker-compose down
6-
docker-compose up -d

client_benchmark_test.go

+54
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,57 @@ func BenchmarkLoginParallel(b *testing.B) {
4646
}
4747
})
4848
}
49+
50+
func BenchmarkGetGroups(b *testing.B) {
51+
cfg := GetConfig(b)
52+
client := gocloak.NewClient(cfg.HostName)
53+
token := GetAdminToken(b, client)
54+
b.ResetTimer()
55+
for i := 0; i < b.N; i++ {
56+
_, err := client.GetGroups(
57+
context.Background(),
58+
token.AccessToken,
59+
cfg.GoCloak.Realm,
60+
gocloak.GetGroupsParams{},
61+
)
62+
assert.NoError(b, err)
63+
}
64+
}
65+
66+
func BenchmarkGetGroupsFull(b *testing.B) {
67+
cfg := GetConfig(b)
68+
client := gocloak.NewClient(cfg.HostName)
69+
token := GetAdminToken(b, client)
70+
params := gocloak.GetGroupsParams{
71+
Full: gocloak.BoolP(true),
72+
}
73+
b.ResetTimer()
74+
for i := 0; i < b.N; i++ {
75+
_, err := client.GetGroups(
76+
context.Background(),
77+
token.AccessToken,
78+
cfg.GoCloak.Realm,
79+
params,
80+
)
81+
assert.NoError(b, err)
82+
}
83+
}
84+
85+
func BenchmarkGetGroupsBrief(b *testing.B) {
86+
cfg := GetConfig(b)
87+
client := gocloak.NewClient(cfg.HostName)
88+
params := gocloak.GetGroupsParams{
89+
BriefRepresentation: gocloak.BoolP(true),
90+
}
91+
token := GetAdminToken(b, client)
92+
b.ResetTimer()
93+
for i := 0; i < b.N; i++ {
94+
_, err := client.GetGroups(
95+
context.Background(),
96+
token.AccessToken,
97+
cfg.GoCloak.Realm,
98+
params,
99+
)
100+
assert.NoError(b, err)
101+
}
102+
}

0 commit comments

Comments
 (0)