keycloak-admin 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +54 -2
- data/keycloak-admin.gemspec +14 -5
- data/lib/keycloak-admin/client/client.rb +30 -11
- data/lib/keycloak-admin/client/client_authz_permission_client.rb +1 -1
- data/lib/keycloak-admin/client/client_authz_policy_client.rb +1 -1
- data/lib/keycloak-admin/client/client_authz_resource_client.rb +1 -1
- data/lib/keycloak-admin/client/client_authz_scope_client.rb +1 -1
- data/lib/keycloak-admin/client/configurable_token_client.rb +2 -1
- data/lib/keycloak-admin/client/group_client.rb +4 -6
- data/lib/keycloak-admin/client/organization_client.rb +7 -7
- data/lib/keycloak-admin/client/resource.rb +98 -0
- data/lib/keycloak-admin/client/response.rb +36 -0
- data/lib/keycloak-admin/client/role_mapper_client.rb +2 -1
- data/lib/keycloak-admin/client/user_client.rb +22 -11
- data/lib/keycloak-admin/configuration.rb +22 -0
- data/lib/keycloak-admin/error.rb +62 -0
- data/lib/keycloak-admin/version.rb +1 -1
- data/lib/keycloak-admin.rb +1 -0
- metadata +38 -53
- data/.github/workflows/Dockerfile +0 -24
- data/.github/workflows/ci.yml +0 -94
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/Dockerfile +0 -13
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -52
- data/bin/console +0 -9
- data/spec/client/attack_detection_client_spec.rb +0 -102
- data/spec/client/client_authz_permission_client_spec.rb +0 -170
- data/spec/client/client_authz_policy_client_spec.rb +0 -170
- data/spec/client/client_authz_resource_client_spec.rb +0 -150
- data/spec/client/client_authz_scope_client_spec.rb +0 -134
- data/spec/client/client_client_spec.rb +0 -133
- data/spec/client/client_role_mappings_client_spec.rb +0 -82
- data/spec/client/client_scope_client_spec.rb +0 -220
- data/spec/client/client_scope_protocol_mapper_client_spec.rb +0 -230
- data/spec/client/client_spec.rb +0 -48
- data/spec/client/configurable_token_client_spec.rb +0 -34
- data/spec/client/group_client_spec.rb +0 -328
- data/spec/client/identity_provider_client_spec.rb +0 -92
- data/spec/client/organization_client_spec.rb +0 -595
- data/spec/client/realm_client_spec.rb +0 -155
- data/spec/client/role_client_spec.rb +0 -79
- data/spec/client/role_mapper_client_spec.rb +0 -113
- data/spec/client/token_client_spec.rb +0 -68
- data/spec/client/user_client_spec.rb +0 -418
- data/spec/configuration_spec.rb +0 -113
- data/spec/gemspec_spec.rb +0 -25
- data/spec/integration/client_authorization_spec.rb +0 -93
- data/spec/representation/attack_detection_representation_spec.rb +0 -16
- data/spec/representation/client_authz_permission_representation_spec.rb +0 -52
- data/spec/representation/client_authz_policy_representation_spec.rb +0 -47
- data/spec/representation/client_authz_resource_representation_spec.rb +0 -33
- data/spec/representation/client_authz_scope_representation_spec.rb +0 -19
- data/spec/representation/client_representation_spec.rb +0 -119
- data/spec/representation/client_scope_representation_spec.rb +0 -125
- data/spec/representation/credential_representation_spec.rb +0 -68
- data/spec/representation/group_representation_spec.rb +0 -22
- data/spec/representation/identity_provider_mapper_representation_spec.rb +0 -24
- data/spec/representation/identity_provider_representation_spec.rb +0 -113
- data/spec/representation/impersonation_representation_spec.rb +0 -163
- data/spec/representation/organization_representation_spec.rb +0 -64
- data/spec/representation/protocol_mapper_representation_spec.rb +0 -57
- data/spec/representation/role_representation_spec.rb +0 -37
- data/spec/representation/session_representation_spec.rb +0 -16
- data/spec/representation/user_representation_spec.rb +0 -15
- data/spec/resource/group_resource_spec.rb +0 -14
- data/spec/resource/user_resource_spec.rb +0 -14
- data/spec/spec_helper.rb +0 -29
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::RealmClient do
|
|
2
|
-
describe "#realm_url" do
|
|
3
|
-
|
|
4
|
-
let(:realm_name) { nil }
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@built_url = KeycloakAdmin.realm(realm_name).realm_url
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context "when realm_name is defined" do
|
|
11
|
-
let(:realm_name) { "master2" }
|
|
12
|
-
it "return a proper url with realm_name" do
|
|
13
|
-
expect(@built_url).to eq "http://auth.service.io/auth/realms/master2"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context "when realm_name is not defined" do
|
|
18
|
-
let(:realm_name) { nil }
|
|
19
|
-
it "return a proper url without realm_name" do
|
|
20
|
-
expect(@built_url).to eq "http://auth.service.io/auth/realms"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe "#admin_realm_url" do
|
|
26
|
-
|
|
27
|
-
let(:realm_name) { nil }
|
|
28
|
-
|
|
29
|
-
before(:each) do
|
|
30
|
-
@built_url = KeycloakAdmin.realm(realm_name).realm_admin_url
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "when realm_name is defined" do
|
|
34
|
-
let(:realm_name) { "master2" }
|
|
35
|
-
it "return a proper url with realm_name" do
|
|
36
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms/master2"
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context "when realm_name is not defined" do
|
|
41
|
-
let(:realm_name) { nil }
|
|
42
|
-
it "return a proper url without realm_name" do
|
|
43
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms"
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe "#list" do
|
|
49
|
-
before(:each) do
|
|
50
|
-
@realm_client = KeycloakAdmin.realm('master')
|
|
51
|
-
|
|
52
|
-
stub_token_client
|
|
53
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '[{"id":"test_realm","realm":"test_realm"}]'
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "lists realms" do
|
|
57
|
-
realms = @realm_client.list
|
|
58
|
-
expect(realms.length).to eq 1
|
|
59
|
-
expect(realms[0].realm).to eq "test_realm"
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "passes rest client options" do
|
|
63
|
-
faraday_options = {timeout: 10}
|
|
64
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
65
|
-
|
|
66
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
67
|
-
"http://auth.service.io/auth/admin/realms", faraday_options).and_call_original
|
|
68
|
-
|
|
69
|
-
realms = @realm_client.list
|
|
70
|
-
expect(realms.length).to eq 1
|
|
71
|
-
expect(realms[0].realm).to eq "test_realm"
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe "#delete" do
|
|
76
|
-
let(:realm_name) { "valid-realm" }
|
|
77
|
-
|
|
78
|
-
before(:each) do
|
|
79
|
-
@realm_client = KeycloakAdmin.realm(realm_name)
|
|
80
|
-
|
|
81
|
-
stub_token_client
|
|
82
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:delete)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "delete realm" do
|
|
86
|
-
expect(@realm_client.delete).to be_truthy
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "passes rest client options" do
|
|
90
|
-
faraday_options = {timeout: 10}
|
|
91
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
92
|
-
|
|
93
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
94
|
-
"http://auth.service.io/auth/admin/realms/valid-realm", faraday_options).and_call_original
|
|
95
|
-
|
|
96
|
-
expect(@realm_client.delete).to be_truthy
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
describe "#save" do
|
|
101
|
-
let(:realm_name) { "valid-realm" }
|
|
102
|
-
let(:realm) { KeycloakAdmin::RealmRepresentation.from_hash(
|
|
103
|
-
"id" => realm_name,
|
|
104
|
-
"realm" => realm_name
|
|
105
|
-
)}
|
|
106
|
-
|
|
107
|
-
before(:each) do
|
|
108
|
-
@realm_client = KeycloakAdmin.realm(nil)
|
|
109
|
-
|
|
110
|
-
stub_token_client
|
|
111
|
-
|
|
112
|
-
expect_any_instance_of(KeycloakAdmin::Resource).to receive(:post).with(realm.to_json, anything)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "saves a realm" do
|
|
116
|
-
@realm_client.save(realm)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "passes rest client options" do
|
|
120
|
-
faraday_options = {timeout: 10}
|
|
121
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
122
|
-
|
|
123
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
124
|
-
"http://auth.service.io/auth/admin/realms", faraday_options).and_call_original
|
|
125
|
-
|
|
126
|
-
@realm_client.save(realm)
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
describe "#update" do
|
|
131
|
-
let(:realm_name) { "valid-realm" }
|
|
132
|
-
let(:realm_json) { { smtpServer: { host: 'test_host' } } }
|
|
133
|
-
|
|
134
|
-
before(:each) do
|
|
135
|
-
@realm_client = KeycloakAdmin.realm(realm_name)
|
|
136
|
-
|
|
137
|
-
stub_token_client
|
|
138
|
-
expect_any_instance_of(KeycloakAdmin::Resource).to receive(:put).with(realm_json.to_json, anything)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "updates a realm" do
|
|
142
|
-
@realm_client.update(realm_json)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "passes rest client options" do
|
|
146
|
-
faraday_options = {timeout: 10}
|
|
147
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
148
|
-
|
|
149
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
150
|
-
"http://auth.service.io/auth/admin/realms/valid-realm", faraday_options).and_call_original
|
|
151
|
-
|
|
152
|
-
@realm_client.update(realm_json)
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::RoleClient do
|
|
2
|
-
describe "#roles_url" do
|
|
3
|
-
let(:realm_name) { "valid-realm" }
|
|
4
|
-
|
|
5
|
-
it "return a proper url without role id" do
|
|
6
|
-
@built_url = KeycloakAdmin.realm(realm_name).roles.roles_url
|
|
7
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/roles"
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#role_id_url" do
|
|
12
|
-
let(:realm_name) { "valid-realm" }
|
|
13
|
-
let(:role_id) { "95985b21-d884-4bbd-b852-cb8cd365afc2" }
|
|
14
|
-
|
|
15
|
-
it "return a proper url with the role id" do
|
|
16
|
-
@built_url = KeycloakAdmin.realm(realm_name).roles.role_id_url(role_id)
|
|
17
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/roles-by-id/95985b21-d884-4bbd-b852-cb8cd365afc2"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe "#list" do
|
|
22
|
-
let(:realm_name) { "valid-realm" }
|
|
23
|
-
|
|
24
|
-
before(:each) do
|
|
25
|
-
@role_client = KeycloakAdmin.realm(realm_name).roles
|
|
26
|
-
|
|
27
|
-
stub_token_client
|
|
28
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '[{"id":"test_role_id","name":"test_role_name"}]'
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "lists roles" do
|
|
32
|
-
roles = @role_client.list
|
|
33
|
-
expect(roles.length).to eq 1
|
|
34
|
-
expect(roles[0].name).to eq "test_role_name"
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "passes rest client options" do
|
|
38
|
-
faraday_options = {timeout: 10}
|
|
39
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
40
|
-
|
|
41
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
42
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/roles", faraday_options).and_call_original
|
|
43
|
-
|
|
44
|
-
roles = @role_client.list
|
|
45
|
-
expect(roles.length).to eq 1
|
|
46
|
-
expect(roles[0].name).to eq "test_role_name"
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe "#save" do
|
|
51
|
-
let(:realm_name) { "valid-realm" }
|
|
52
|
-
let(:role) { KeycloakAdmin::RoleRepresentation.from_hash(
|
|
53
|
-
"name" => "test_role_name",
|
|
54
|
-
"composite" => false,
|
|
55
|
-
"clientRole" => false
|
|
56
|
-
)}
|
|
57
|
-
|
|
58
|
-
before(:each) do
|
|
59
|
-
@role_client = KeycloakAdmin.realm(realm_name).roles
|
|
60
|
-
|
|
61
|
-
stub_token_client
|
|
62
|
-
expect_any_instance_of(KeycloakAdmin::Resource).to receive(:post).with(role.to_json, anything)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "saves a role" do
|
|
66
|
-
@role_client.save(role)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "passes rest client options" do
|
|
70
|
-
faraday_options = {timeout: 10}
|
|
71
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
72
|
-
|
|
73
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
74
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/roles", faraday_options).and_call_original
|
|
75
|
-
|
|
76
|
-
@role_client.save(role)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::RoleMapperClient do
|
|
2
|
-
describe "#available_url" do
|
|
3
|
-
let(:realm_name) { "valid-realm" }
|
|
4
|
-
let(:user_id) { "test_user" }
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@built_url = KeycloakAdmin.realm(realm_name).user(user_id).role_mapper.realm_level_url
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "return a proper url" do
|
|
11
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/users/test_user/role-mappings/realm"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe "#list" do
|
|
16
|
-
let(:realm_name) { "valid-realm" }
|
|
17
|
-
let(:user_id) { "test_user" }
|
|
18
|
-
|
|
19
|
-
before(:each) do
|
|
20
|
-
@role_mapper_client = KeycloakAdmin.realm(realm_name).user(user_id).role_mapper
|
|
21
|
-
|
|
22
|
-
stub_token_client
|
|
23
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get)
|
|
24
|
-
.and_return '[{"id":"test_role_id","name":"test_role_name","composite": false}]'
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "list user realm-level role mappings" do
|
|
28
|
-
roles = @role_mapper_client.list
|
|
29
|
-
expect(roles.length).to eq 1
|
|
30
|
-
expect(roles[0].id).to eq "test_role_id"
|
|
31
|
-
expect(roles[0].name).to eq "test_role_name"
|
|
32
|
-
expect(roles[0].composite).to be false
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe "#save_realm_level" do
|
|
37
|
-
let(:realm_name) { "valid-realm" }
|
|
38
|
-
let(:user_id) { "test_user" }
|
|
39
|
-
let(:role_list) { [
|
|
40
|
-
KeycloakAdmin::RoleRepresentation.from_hash(
|
|
41
|
-
"name" => "test_role_name",
|
|
42
|
-
"composite" => false,
|
|
43
|
-
"clientRole" => false
|
|
44
|
-
)
|
|
45
|
-
] }
|
|
46
|
-
|
|
47
|
-
before(:each) do
|
|
48
|
-
@role_mapper_client = KeycloakAdmin.realm(realm_name).user(user_id).role_mapper
|
|
49
|
-
|
|
50
|
-
stub_token_client
|
|
51
|
-
expect_any_instance_of(KeycloakAdmin::Resource).to receive(:post).with(role_list.to_json, anything)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "saves realm-elevel role mappings" do
|
|
55
|
-
@role_mapper_client.save_realm_level(role_list)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "passes rest client options" do
|
|
59
|
-
faraday_options = {timeout: 10}
|
|
60
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
61
|
-
|
|
62
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
63
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/users/test_user/role-mappings/realm", faraday_options).and_call_original
|
|
64
|
-
|
|
65
|
-
@role_mapper_client.save_realm_level(role_list)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe "#remove_realm_level" do
|
|
70
|
-
let(:realm_name) { "valid-realm" }
|
|
71
|
-
let(:user_id) { "test_user" }
|
|
72
|
-
let(:role_list) { [
|
|
73
|
-
KeycloakAdmin::RoleRepresentation.from_hash(
|
|
74
|
-
"id" => "d9e3376b-f602-4086-8eee-89fea73c73ea"
|
|
75
|
-
)
|
|
76
|
-
] }
|
|
77
|
-
let(:expected_url) { "http://auth.service.io/auth/admin/realms/valid-realm/users/test_user/role-mappings/realm" }
|
|
78
|
-
|
|
79
|
-
before(:each) do
|
|
80
|
-
@role_mapper_client = KeycloakAdmin.realm(realm_name).user(user_id).role_mapper
|
|
81
|
-
|
|
82
|
-
stub_token_client
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "removes realm-level role mappings" do
|
|
86
|
-
expect(KeycloakAdmin::Resource).to receive(:execute).with(
|
|
87
|
-
hash_including(
|
|
88
|
-
method: :delete,
|
|
89
|
-
url: expected_url,
|
|
90
|
-
payload: role_list.to_json
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
@role_mapper_client.remove_realm_level(role_list)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "passes rest client options" do
|
|
98
|
-
faraday_options = {timeout: 10}
|
|
99
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
100
|
-
|
|
101
|
-
expect(KeycloakAdmin::Resource).to receive(:execute).with(
|
|
102
|
-
hash_including(
|
|
103
|
-
method: :delete,
|
|
104
|
-
url: expected_url,
|
|
105
|
-
payload: role_list.to_json,
|
|
106
|
-
timeout: 10
|
|
107
|
-
)
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
@role_mapper_client.remove_realm_level(role_list)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::TokenClient do
|
|
2
|
-
describe "#initialize" do
|
|
3
|
-
let(:realm_name) { nil }
|
|
4
|
-
before(:each) do
|
|
5
|
-
@realm = KeycloakAdmin.realm(realm_name)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
context "when realm_name is defined" do
|
|
9
|
-
let(:realm_name) { "master" }
|
|
10
|
-
it "does not raise any error" do
|
|
11
|
-
expect {
|
|
12
|
-
@realm.token
|
|
13
|
-
}.to_not raise_error
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context "when realm_name is not defined" do
|
|
18
|
-
let(:realm_name) { nil }
|
|
19
|
-
it "raises any error" do
|
|
20
|
-
expect {
|
|
21
|
-
@realm.token
|
|
22
|
-
}.to raise_error(ArgumentError)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe "#token_url" do
|
|
28
|
-
let(:realm_name) { "valid-realm" }
|
|
29
|
-
before(:each) do
|
|
30
|
-
@built_url = KeycloakAdmin.realm(realm_name).token.token_url
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "returns a proper url" do
|
|
34
|
-
expect(@built_url).to eq "http://auth.service.io/auth/realms/valid-realm/protocol/openid-connect/token"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "#get" do
|
|
39
|
-
let(:realm_name) { "valid-realm" }
|
|
40
|
-
before(:each) do
|
|
41
|
-
@token_client = KeycloakAdmin.realm(realm_name).token
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "parses the response" do
|
|
45
|
-
stub_post
|
|
46
|
-
|
|
47
|
-
token = @token_client.get
|
|
48
|
-
expect(token.access_token).to eq 'test_access_token'
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "passes rest client options" do
|
|
52
|
-
faraday_options = {timeout: 10}
|
|
53
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
54
|
-
stub_post
|
|
55
|
-
|
|
56
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
57
|
-
"http://auth.service.io/auth/realms/valid-realm/protocol/openid-connect/token", faraday_options).and_call_original
|
|
58
|
-
|
|
59
|
-
@token_client.get
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def stub_post
|
|
63
|
-
response = double
|
|
64
|
-
allow(response).to receive(:body).and_return '{"access_token":"test_access_token"}'
|
|
65
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return response
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|