bridge_api 0.1.26 → 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb2cd7d2e2a8d97e6208fd6632e8173b887b3f20
4
- data.tar.gz: e51fe0b7a828425949945f66c0d2b878f1c3c66a
3
+ metadata.gz: 6fe6414fe4379427b35d713bcb22215bcaaac955
4
+ data.tar.gz: ef6af928d02d5e9d3c55da7a89f82cbfc862a066
5
5
  SHA512:
6
- metadata.gz: 6c6e545210b976756053fee121b2e937f82900b17e00c76f05b7d87781de83fe0be29a4771ac0707591437ec12b0ff375f53201048f4e12d4b78648932a46d63
7
- data.tar.gz: 0c260c24d9653f688e84a89a14debeb4c8f25acf1953dc754b708602e7384db9aac65eb269447c734231979ff48413ff7956025d756c4c99c2d8219bf90c0525
6
+ metadata.gz: c99339c9dcb18858fbdb2ac8163ffd0aaebd62c70624c59d503475bb4ad895bca604a378a0c6a826fbde3af1a1a184f0a42889e2e25def866b9abbc4da738121
7
+ data.tar.gz: 6c36f3dbf2f26e641172f301c04210f8c8eef5e625aeaa66e635967c0d2e9f0d09f5e1be81b2dea69d73d1328cf701ccb9ef0ffe248c2e41de37f75eaa854454
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bridge_api (0.1.25)
4
+ bridge_api (0.1.27)
5
5
  faraday (~> 0.9.0)
6
6
  faraday_middleware (~> 0.9.0)
7
7
  footrest (>= 0.5.1)
@@ -8,6 +8,14 @@ module BridgeAPI
8
8
  def get_role(role_id, params = {})
9
9
  get("#{API_PATH}#{AUTHOR_PATH}#{ROLE_PATH}/#{role_id}", params)
10
10
  end
11
+
12
+ def create_role(params = {})
13
+ post("#{API_PATH}#{AUTHOR_PATH}#{ROLE_PATH}", params)
14
+ end
15
+
16
+ def delete_role(role_id, params = {})
17
+ delete("#{API_PATH}#{AUTHOR_PATH}#{ROLE_PATH}/#{role_id}", params)
18
+ end
11
19
  end
12
20
  end
13
21
  end
@@ -33,6 +33,10 @@ module BridgeAPI
33
33
  get("#{API_PATH}#{AUTHOR_PATH}#{USER_PATH}", params)
34
34
  end
35
35
 
36
+ def add_user_to_role_batch(user_id, params = {})
37
+ put("#{API_PATH}#{ADMIN_PATH}#{USER_PATH}/#{user_id}#{ROLE_PATH}", params)
38
+ end
39
+
36
40
  private
37
41
 
38
42
  #++user_id++ Bridge user ID
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.1.26'.freeze unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.1.27'.freeze unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ describe BridgeAPI::Client::Role do
4
+ before do
5
+ @client = BridgeAPI::Client.new(prefix: 'http://test.bridge.com', token: 'test_token')
6
+ end
7
+
8
+ it 'should get all roles' do
9
+ response = @client.get_all_roles
10
+ expect(response.members.size).to eq(1)
11
+ end
12
+
13
+ it 'should get a role' do
14
+ response = @client.get_role(1)
15
+ expect(response.members.size).to eq(1)
16
+ end
17
+
18
+ it 'should create a role' do
19
+ response = @client.create_role({})
20
+ expect(response.members.size).to eq(1)
21
+ end
22
+
23
+ it 'should delete a role' do
24
+ response = @client.delete_role(1, {})
25
+ expect(response.status).to eq(204)
26
+ end
27
+ end
@@ -32,4 +32,10 @@ describe BridgeAPI::Client::User do
32
32
  response = @client.get_all_users
33
33
  expect(response.length).to(eq(2))
34
34
  end
35
+
36
+ it 'should add roles by batch for a user' do
37
+ response = @client.add_user_to_role_batch(1)
38
+ expect(response.length).to eq(7)
39
+ end
40
+
35
41
  end
@@ -0,0 +1,27 @@
1
+ {
2
+ "roles": [
3
+ {
4
+ "id": "72c2c9d5-11a4-4093-857f-7c5dc3b0d8cb",
5
+ "name": "tester",
6
+ "permissions": [
7
+ "role_view",
8
+ "user_view",
9
+ "user_create",
10
+ "user_update",
11
+ "user_destroy",
12
+ "user_self_update",
13
+ "user_uid_update",
14
+ "group_create",
15
+ "group_update",
16
+ "group_view",
17
+ "group_destroy",
18
+ "membership_create",
19
+ "membership_destroy",
20
+ "group_enrollment_create",
21
+ "live_course_group_enrollment_create",
22
+ "program_group_enrollment_create"
23
+ ],
24
+ "is_computed": false
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "meta": {},
3
+ "roles": [
4
+ {
5
+ "id": 169,
6
+ "user_id": 305,
7
+ "domain_id": 1,
8
+ "created_at": "2018-06-21T14:42:29.267-06:00",
9
+ "updated_at": "2018-06-21T14:42:29.267-06:00",
10
+ "deleted_at": null,
11
+ "role_id": "803561cd-77a6-49a3-9438-35498a8b593a"
12
+ },
13
+ {
14
+ "id": 162,
15
+ "user_id": 305,
16
+ "domain_id": 1,
17
+ "created_at": "2018-06-12T12:33:37.470-06:00",
18
+ "updated_at": "2018-06-12T12:33:37.470-06:00",
19
+ "deleted_at": null,
20
+ "role_id": "it_admin"
21
+ },
22
+ {
23
+ "id": 161,
24
+ "user_id": 305,
25
+ "domain_id": 1,
26
+ "created_at": "2018-06-12T12:33:37.437-06:00",
27
+ "updated_at": "2018-06-12T12:33:37.437-06:00",
28
+ "deleted_at": null,
29
+ "role_id": "admin"
30
+ },
31
+ {
32
+ "id": 160,
33
+ "user_id": 305,
34
+ "domain_id": 1,
35
+ "created_at": "2018-06-12T12:33:37.403-06:00",
36
+ "updated_at": "2018-06-12T12:33:37.403-06:00",
37
+ "deleted_at": null,
38
+ "role_id": "account_admin"
39
+ },
40
+ {
41
+ "id": 159,
42
+ "user_id": 305,
43
+ "domain_id": 1,
44
+ "created_at": "2018-06-12T12:33:37.370-06:00",
45
+ "updated_at": "2018-06-12T12:33:37.370-06:00",
46
+ "deleted_at": null,
47
+ "role_id": "99af7f72-f4fc-4d59-b667-d5f7388b8f7e"
48
+ },
49
+ {
50
+ "id": 158,
51
+ "user_id": 305,
52
+ "domain_id": 1,
53
+ "created_at": "2018-06-12T12:33:37.331-06:00",
54
+ "updated_at": "2018-06-12T12:33:37.331-06:00",
55
+ "deleted_at": null,
56
+ "role_id": "3ad463df-fc30-4130-8fcd-195006f00f86"
57
+ },
58
+ {
59
+ "id": 32,
60
+ "user_id": 305,
61
+ "domain_id": 1,
62
+ "created_at": "2017-11-16T14:38:21.280-07:00",
63
+ "updated_at": "2017-11-16T14:38:21.280-07:00",
64
+ "deleted_at": null,
65
+ "role_id": "author"
66
+ }
67
+ ]
68
+ }
@@ -197,6 +197,23 @@ class FakeBridge < Sinatra::Base
197
197
  get_json_data 200, 'accounts.json'
198
198
  end
199
199
 
200
+ #Roles
201
+ get %r{/api/author/roles} do
202
+ get_json_data 200, 'roles.json'
203
+ end
204
+
205
+ post %r{/api/author/roles} do
206
+ get_json_data 200, 'roles.json'
207
+ end
208
+
209
+ put %r{/api/admin/users/\d+/roles} do
210
+ get_json_data 200, 'user_roles_add.json'
211
+ end
212
+
213
+ delete %r{/api/author/roles} do
214
+ get_json_data 204, 'roles.json'
215
+ end
216
+
200
217
  private
201
218
 
202
219
  def get_json_data(response_code, file_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2018-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -220,6 +220,7 @@ files:
220
220
  - spec/bridge_api/client/live_course_spec.rb
221
221
  - spec/bridge_api/client/manager_spec.rb
222
222
  - spec/bridge_api/client/program_enrollment_spec.rb
223
+ - spec/bridge_api/client/role_spec.rb
223
224
  - spec/bridge_api/client/sub_account_spec.rb
224
225
  - spec/bridge_api/client/user_spec.rb
225
226
  - spec/bridge_api/client_spec.rb
@@ -239,10 +240,12 @@ files:
239
240
  - spec/fixtures/managers.json
240
241
  - spec/fixtures/program_enrollments.json
241
242
  - spec/fixtures/programs.json
243
+ - spec/fixtures/roles.json
242
244
  - spec/fixtures/sub_account_lti_config.json
243
245
  - spec/fixtures/sub_account_lti_config_update.json
244
246
  - spec/fixtures/sub_accounts.json
245
247
  - spec/fixtures/user.json
248
+ - spec/fixtures/user_roles_add.json
246
249
  - spec/fixtures/users.json
247
250
  - spec/support/fake_bridge.rb
248
251
  - spec/test_helper.rb
@@ -282,6 +285,7 @@ test_files:
282
285
  - spec/bridge_api/client/live_course_spec.rb
283
286
  - spec/bridge_api/client/manager_spec.rb
284
287
  - spec/bridge_api/client/program_enrollment_spec.rb
288
+ - spec/bridge_api/client/role_spec.rb
285
289
  - spec/bridge_api/client/sub_account_spec.rb
286
290
  - spec/bridge_api/client/user_spec.rb
287
291
  - spec/bridge_api/client_spec.rb
@@ -301,10 +305,12 @@ test_files:
301
305
  - spec/fixtures/managers.json
302
306
  - spec/fixtures/program_enrollments.json
303
307
  - spec/fixtures/programs.json
308
+ - spec/fixtures/roles.json
304
309
  - spec/fixtures/sub_account_lti_config.json
305
310
  - spec/fixtures/sub_account_lti_config_update.json
306
311
  - spec/fixtures/sub_accounts.json
307
312
  - spec/fixtures/user.json
313
+ - spec/fixtures/user_roles_add.json
308
314
  - spec/fixtures/users.json
309
315
  - spec/support/fake_bridge.rb
310
316
  - spec/test_helper.rb