code42 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/code42.gemspec +3 -0
  4. data/lib/code42.rb +66 -27
  5. data/lib/code42/api/destination.rb +18 -0
  6. data/lib/code42/api/diagnostic.rb +9 -0
  7. data/lib/code42/api/org.rb +5 -2
  8. data/lib/code42/api/product_license.rb +21 -0
  9. data/lib/code42/api/server.rb +21 -0
  10. data/lib/code42/api/server_connection_string.rb +9 -0
  11. data/lib/code42/api/server_settings.rb +13 -0
  12. data/lib/code42/api/store_point.rb +22 -0
  13. data/lib/code42/api/token.rb +7 -0
  14. data/lib/code42/client.rb +23 -31
  15. data/lib/code42/computer.rb +0 -2
  16. data/lib/code42/connection.rb +14 -26
  17. data/lib/code42/destination.rb +52 -0
  18. data/lib/code42/product_license.rb +12 -0
  19. data/lib/code42/server.rb +54 -0
  20. data/lib/code42/server_connection_string.rb +10 -0
  21. data/lib/code42/server_settings.rb +4 -0
  22. data/lib/code42/settings.rb +1 -1
  23. data/lib/code42/store_point.rb +63 -0
  24. data/lib/code42/version.rb +1 -1
  25. data/spec/cassettes/Code42_Client/_add_product_license/adds_a_product_license.yml +39 -0
  26. data/spec/cassettes/Code42_Client/_apply_mlk/applies_the_mlk.yml +77 -0
  27. data/spec/cassettes/Code42_Client/_create_destination/creates_a_destination.yml +40 -0
  28. data/spec/cassettes/Code42_Client/_create_server/creates_a_server.yml +38 -0
  29. data/spec/cassettes/Code42_Client/_destination/returns_a_destination.yml +37 -0
  30. data/spec/cassettes/Code42_Client/_destinations/returns_an_array_of_desinations.yml +37 -0
  31. data/spec/cassettes/Code42_Client/_org_share_destinations/returns_a_provider_key.yml +36 -0
  32. data/spec/cassettes/Code42_Client/_product_licenses/returns_an_array_of_product_licenses.yml +81 -0
  33. data/spec/cassettes/Code42_Client/_remove_product_license/removes_a_product_license.yml +104 -0
  34. data/spec/cassettes/Code42_Client/_server/returns_a_server.yml +37 -0
  35. data/spec/cassettes/Code42_Client/_server_connection_string/returns_a_connection_string.yml +36 -0
  36. data/spec/cassettes/Code42_Client/_server_settings/returns_a_server_settings_object.yml +37 -0
  37. data/spec/cassettes/Code42_Client/_servers/returns_an_array_of_servers.yml +37 -0
  38. data/spec/cassettes/Code42_Client/_update_product_license/updates_a_product_license.yml +76 -0
  39. data/spec/cassettes/Code42_Client/_update_server_settings/updates_server_settings.yml +70 -0
  40. data/spec/cassettes/Code42_StorePoint/_accept_new_devices/should_return_store_point_with_accept_new_devices_enabled.yml +75 -0
  41. data/spec/cassettes/Code42_StorePoint/_disable_balancing/should_return_store_point_with_balancing_enabled.yml +75 -0
  42. data/spec/cassettes/Code42_StorePoint/_disable_inbound_backup/should_return_store_point_with_inbound_backup_disabled.yml +75 -0
  43. data/spec/cassettes/Code42_StorePoint/_enable_balancing/should_return_store_point_with_balancing_enabled.yml +75 -0
  44. data/spec/cassettes/Code42_StorePoint/_enable_inbound_backup/should_return_store_point_with_inbound_backup_disabled.yml +75 -0
  45. data/spec/cassettes/Code42_StorePoint/_find_store_point_by_id/should_return_correct_store_point.yml +38 -0
  46. data/spec/cassettes/Code42_StorePoint/_find_store_point_by_name/should_return_correct_store_point.yml +38 -0
  47. data/spec/cassettes/Code42_StorePoint/_find_store_point_by_server_name/should_return_correct_store_point.yml +38 -0
  48. data/spec/cassettes/Code42_StorePoint/_reject_new_devices/should_return_store_point_with_accept_new_devices_disabled.yml +75 -0
  49. data/spec/code42/client_spec.rb +161 -57
  50. data/spec/code42/connection_spec.rb +10 -12
  51. data/spec/code42/extension_spec.rb +0 -2
  52. data/spec/code42/org_spec.rb +20 -22
  53. data/spec/code42/ping_spec.rb +1 -3
  54. data/spec/code42/product_license_spec.rb +34 -0
  55. data/spec/code42/resource_spec.rb +0 -2
  56. data/spec/code42/role_spec.rb +2 -4
  57. data/spec/code42/server_connection_string_spec.rb +34 -0
  58. data/spec/code42/server_spec.rb +66 -0
  59. data/spec/code42/settings_spec.rb +25 -27
  60. data/spec/code42/store_point_spec.rb +90 -0
  61. data/spec/code42/token_spec.rb +10 -15
  62. data/spec/code42/user_spec.rb +4 -6
  63. data/spec/spec_helper.rb +1 -1
  64. metadata +74 -4
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:admin@10.10.40.57:4280/api/storePoint/2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - no-store
23
+ Pragma:
24
+ - no-cache
25
+ Content-Location:
26
+ - http://10.10.40.57:4280/api/v1/storePoint/2
27
+ Content-Type:
28
+ - application/json;charset=UTF-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Server:
32
+ - Jetty(7.6.3.v20120416)
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"metadata":{"timestamp":"2014-08-30T17:29:12.721Z","params":{}},"data":{"storePointId":2,"storePointName":"651951667247317249_Default","note":null,"path":"/var/opt/proserver/backupArchives","directory":"CrashPlanArchive_Default","absolutePath":"/var/opt/proserver/backupArchives/CrashPlanArchive_Default","serverId":5,"serverName":"test_storage_node","destinationId":4,"destinationName":"local-storage","backupSessionCount":0,"computerCount":0,"backupComputerCount":0,"userCount":0,"licensedUserCount":0,"orgCount":0,"usedBytes":4657938432,"usedPercentage":22.0,"freeBytes":16478859264,"freeBytesAlert":"null","freePercentage":78.0,"coldBytes":0,"coldPercentageOfUsed":0.0,"coldPercentageOfTotal":0.0,"totalBytes":21136797696,"acceptingInboundBackup":true,"balancingData":true,"acceptingNewComputers":true,"writeSpeed":null,"online":true,"serverOnline":true,"archiveBytes":0,"selectedBytes":0,"todoBytes":0}}'
36
+ http_version:
37
+ recorded_at: Sat, 30 Aug 2014 17:29:12 GMT
38
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:admin@10.10.40.57:4280/api/storePoint?q=651951667247317249_Default
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - no-store
23
+ Pragma:
24
+ - no-cache
25
+ Content-Location:
26
+ - http://10.10.40.57:4280/api/v1/storePoint?q=651951667247317249_Default
27
+ Content-Type:
28
+ - application/json;charset=UTF-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Server:
32
+ - Jetty(7.6.3.v20120416)
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"metadata":{"timestamp":"2014-08-30T17:29:18.686Z","params":{"q":"651951667247317249_Default"}},"data":{"totalCount":1,"storepoints":[{"storePointId":2,"storePointName":"651951667247317249_Default","note":null,"path":"/var/opt/proserver/backupArchives","directory":"CrashPlanArchive_Default","absolutePath":"/var/opt/proserver/backupArchives/CrashPlanArchive_Default","serverId":5,"serverName":"test_storage_node","destinationId":4,"destinationName":"local-storage","backupSessionCount":0,"computerCount":0,"backupComputerCount":0,"userCount":0,"licensedUserCount":0,"orgCount":0,"usedBytes":4657950720,"usedPercentage":22.0,"freeBytes":16478846976,"freeBytesAlert":"null","freePercentage":78.0,"coldBytes":0,"coldPercentageOfUsed":0.0,"coldPercentageOfTotal":0.0,"totalBytes":21136797696,"acceptingInboundBackup":false,"balancingData":false,"acceptingNewComputers":false,"writeSpeed":null,"online":true,"serverOnline":true,"archiveBytes":0,"selectedBytes":0,"todoBytes":0}]}}'
36
+ http_version:
37
+ recorded_at: Sat, 30 Aug 2014 17:29:18 GMT
38
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:admin@10.10.40.57:4280/api/storePoint?q=test_storage_node
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - no-store
23
+ Pragma:
24
+ - no-cache
25
+ Content-Location:
26
+ - http://10.10.40.57:4280/api/v1/storePoint?q=test_storage_node
27
+ Content-Type:
28
+ - application/json;charset=UTF-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Server:
32
+ - Jetty(7.6.3.v20120416)
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"metadata":{"timestamp":"2014-08-30T17:29:14.011Z","params":{"q":"test_storage_node"}},"data":{"totalCount":1,"storepoints":[{"storePointId":2,"storePointName":"651951667247317249_Default","note":null,"path":"/var/opt/proserver/backupArchives","directory":"CrashPlanArchive_Default","absolutePath":"/var/opt/proserver/backupArchives/CrashPlanArchive_Default","serverId":5,"serverName":"test_storage_node","destinationId":4,"destinationName":"local-storage","backupSessionCount":0,"computerCount":0,"backupComputerCount":0,"userCount":0,"licensedUserCount":0,"orgCount":0,"usedBytes":4657938432,"usedPercentage":22.0,"freeBytes":16478859264,"freeBytesAlert":"null","freePercentage":78.0,"coldBytes":0,"coldPercentageOfUsed":0.0,"coldPercentageOfTotal":0.0,"totalBytes":21136797696,"acceptingInboundBackup":true,"balancingData":true,"acceptingNewComputers":true,"writeSpeed":null,"online":true,"serverOnline":true,"archiveBytes":0,"selectedBytes":0,"todoBytes":0}]}}'
36
+ http_version:
37
+ recorded_at: Sat, 30 Aug 2014 17:29:13 GMT
38
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:admin@10.10.40.57:4280/api/storePoint/2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - no-store
23
+ Pragma:
24
+ - no-cache
25
+ Content-Location:
26
+ - http://10.10.40.57:4280/api/v1/storePoint/2
27
+ Content-Type:
28
+ - application/json;charset=UTF-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Server:
32
+ - Jetty(7.6.3.v20120416)
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"metadata":{"timestamp":"2014-08-30T18:27:30.187Z","params":{}},"data":{"storePointId":2,"storePointName":"651951667247317249_Default","note":null,"path":"/var/opt/proserver/backupArchives","directory":"CrashPlanArchive_Default","absolutePath":"/var/opt/proserver/backupArchives/CrashPlanArchive_Default","serverId":5,"serverName":"test_storage_node","destinationId":4,"destinationName":"local-storage","backupSessionCount":0,"computerCount":0,"backupComputerCount":0,"userCount":0,"licensedUserCount":0,"orgCount":0,"usedBytes":4658135040,"usedPercentage":22.0,"freeBytes":16478662656,"freeBytesAlert":"null","freePercentage":78.0,"coldBytes":0,"coldPercentageOfUsed":0.0,"coldPercentageOfTotal":0.0,"totalBytes":21136797696,"acceptingInboundBackup":true,"balancingData":true,"acceptingNewComputers":true,"writeSpeed":null,"online":true,"serverOnline":true,"archiveBytes":0,"selectedBytes":0,"todoBytes":0}}'
36
+ http_version:
37
+ recorded_at: Sat, 30 Aug 2014 18:27:29 GMT
38
+ - request:
39
+ method: put
40
+ uri: http://admin:admin@10.10.40.57:4280/api/storePoint/2
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"acceptingNewComputers":false}'
44
+ headers:
45
+ User-Agent:
46
+ - Faraday v0.9.0
47
+ Content-Type:
48
+ - application/json
49
+ Accept-Encoding:
50
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
51
+ Accept:
52
+ - '*/*'
53
+ response:
54
+ status:
55
+ code: 200
56
+ message: OK
57
+ headers:
58
+ Cache-Control:
59
+ - no-store
60
+ Pragma:
61
+ - no-cache
62
+ Content-Location:
63
+ - http://10.10.40.57:4280/api/v1/storePoint/2
64
+ Content-Type:
65
+ - application/json;charset=UTF-8
66
+ Transfer-Encoding:
67
+ - chunked
68
+ Server:
69
+ - Jetty(7.6.3.v20120416)
70
+ body:
71
+ encoding: UTF-8
72
+ string: '{"metadata":{"timestamp":"2014-08-30T18:27:30.818Z","params":{}},"data":{"storePointId":2,"storePointName":"651951667247317249_Default","note":null,"path":"/var/opt/proserver/backupArchives","directory":"CrashPlanArchive_Default","absolutePath":"/var/opt/proserver/backupArchives/CrashPlanArchive_Default","serverId":5,"serverName":"test_storage_node","destinationId":4,"destinationName":"local-storage","backupSessionCount":0,"computerCount":0,"backupComputerCount":0,"userCount":0,"licensedUserCount":0,"orgCount":0,"usedBytes":4658135040,"usedPercentage":22.0,"freeBytes":16478662656,"freeBytesAlert":"null","freePercentage":78.0,"coldBytes":0,"coldPercentageOfUsed":0.0,"coldPercentageOfTotal":0.0,"totalBytes":21136797696,"acceptingInboundBackup":true,"balancingData":true,"acceptingNewComputers":false,"writeSpeed":null,"online":true,"serverOnline":true,"archiveBytes":0,"selectedBytes":0,"todoBytes":0}}'
73
+ http_version:
74
+ recorded_at: Sat, 30 Aug 2014 18:27:30 GMT
75
+ recorded_with: VCR 2.5.0
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Code42::Client, :vcr do
4
2
 
5
3
  subject(:client) do
@@ -9,31 +7,136 @@ describe Code42::Client, :vcr do
9
7
  https: false,
10
8
  api_root: '/api',
11
9
  username: 'admin',
12
- password: 'admin'
10
+ password: 'admin',
11
+ verify_https: false,
12
+ debug: true
13
13
  )
14
14
  end
15
15
 
16
- describe "#validate_token" do
17
- it "returns a valid response" do
16
+ describe '#server_connection_string' do
17
+ it 'returns a connection string' do
18
+ connection_string = client.server_connection_string(3)
19
+ connection_string.should be_a(Code42::ServerConnectionString)
20
+ connection_string.server_id.should == 3
21
+ end
22
+ end
23
+
24
+ describe '#org_share_destinations' do
25
+ it 'returns a provider key' do
26
+ client.org_share_destinations(5).should == 'rO0ABXQCnSI2MDA3ODIyNTE5MDIzNzAwNDkifHwiNjAwNzgyMTgzNjg2MjA5NzkzInx8IkNyYXNoUGxhbiBQUk9lIFNlcnZlciJ8fCJ1cms4Mm1tMjRtdzc4amNjInx8IjEwLjEwLjQ2LjEzNzo0MjgyInx8Im51bGwifHwiMTAuMTAuNDYuMTM3OjQyODYifHwiMTAuMTAuNDYuMTM3OjQyODMifHwiaHR0cDovLzEwLjEwLjQ2LjEzNzo0MjgwInx8Ik1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBb2hoeXdmYUpTWDh2RzZmK2JvR3ZDeGJPUzJrdk8yRlRIQUdJUGJtb0kwUUphd2gxZ3ZPQVFUQk5WeHY2Y1k4R1hKckphelI4dUl0UGQ3ZFNHNFNTbFYyR2FsT09WVUJuRitpUGQ2T1E2cDBhaVgvR1JIcjNqaTU2ZVNNNW1yYlUvTmQybGVKMSttV1Z2UkhOQ2ErTXFWbWQ3K3dNYkJvZk5aeGRSbzhZRk1SSVVMVFJEZk1MRFJLbnZUWUgzRk5vMCt6STZkb1RUeHpueXdTWXlqN0hEbkRDbW4yZGs4WnJwbnNpRkZHU3NDRUxPWXUraDZEUVppTkhlVDdwNWMzYnhSSW1tU2VxOUtPRmxkSlhZYk9ZSXB4TVE0QUtnYXYyWk9RWlBKZkIxOTJNek8rK25TY1B4Z1R6SVR4Nmw1N0xIY3Fzc1RPaFV3Z29JSm9ncTJDZzl3SURBUUFCInx8IlBST1ZJREVSInx8Ijgya21yOGo5a3Bjdzk5cHMifHwiNjAwNzgyMjUyMDE5ODEwNTYxInx8IkNyYXNoUGxhbiBQUk9lIFNlcnZlciJ8fCJudWxsIg=='
27
+ end
28
+ end
29
+
30
+ describe '#server_settings' do
31
+ it 'returns a server settings object' do
32
+ client.server_settings(1).should be_a(Code42::ServerSettings)
33
+ end
34
+ end
35
+
36
+ describe '#server' do
37
+ it 'returns a server' do
38
+ server = client.server(3)
39
+ server.should be_a(Code42::Server)
40
+ server.id.should == 3
41
+ end
42
+ end
43
+
44
+ describe '#update_server_settings' do
45
+ it 'updates server settings' do
46
+ client.update_server_settings(1, name: 'Foo Bar Server')
47
+ client.server_settings(1).name.should == 'Foo Bar Server'
48
+ end
49
+ end
50
+
51
+ describe '#destinations' do
52
+ it 'returns an array of desinations' do
53
+ destinations = client.destinations
54
+ destinations.should be_an(Array)
55
+ destinations.first.should be_a(Code42::Destination)
56
+ end
57
+ end
58
+
59
+ describe '#create_destination' do
60
+ it 'creates a destination' do
61
+ destination = client.create_destination(provider: true, destination_name: 'aaa', provider_key: 'rO0ABXQCnSI2MDA3ODIyNTE5MDIzNzAwNDkifHwiNjAwNzgyMTgzNjg2MjA5NzkzInx8IkNyYXNoUGxhbiBQUk9lIFNlcnZlciJ8fCJ1cms4Mm1tMjRtdzc4amNjInx8IjEwLjEwLjQ2LjEzNzo0MjgyInx8Im51bGwifHwiMTAuMTAuNDYuMTM3OjQyODYifHwiMTAuMTAuNDYuMTM3OjQyODMifHwiaHR0cDovLzEwLjEwLjQ2LjEzNzo0MjgwInx8Ik1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBb2hoeXdmYUpTWDh2RzZmK2JvR3ZDeGJPUzJrdk8yRlRIQUdJUGJtb0kwUUphd2gxZ3ZPQVFUQk5WeHY2Y1k4R1hKckphelI4dUl0UGQ3ZFNHNFNTbFYyR2FsT09WVUJuRitpUGQ2T1E2cDBhaVgvR1JIcjNqaTU2ZVNNNW1yYlUvTmQybGVKMSttV1Z2UkhOQ2ErTXFWbWQ3K3dNYkJvZk5aeGRSbzhZRk1SSVVMVFJEZk1MRFJLbnZUWUgzRk5vMCt6STZkb1RUeHpueXdTWXlqN0hEbkRDbW4yZGs4WnJwbnNpRkZHU3NDRUxPWXUraDZEUVppTkhlVDdwNWMzYnhSSW1tU2VxOUtPRmxkSlhZYk9ZSXB4TVE0QUtnYXYyWk9RWlBKZkIxOTJNek8rK25TY1B4Z1R6SVR4Nmw1N0xIY3Fzc1RPaFV3Z29JSm9ncTJDZzl3SURBUUFCInx8IlBST1ZJREVSInx8IjRtOWhqNDJrd3BwY21yc20ifHwiNjAwNzgyMjUyMDE5ODEwNTYxInx8IkNyYXNoUGxhbiBQUk9lIFNlcnZlciJ8fCJudWxsIg==')
62
+ destination.should be_true
63
+ end
64
+ end
65
+
66
+ describe '#servers' do
67
+ it 'returns an array of servers' do
68
+ client.servers.should be_an(Array)
69
+ end
70
+ end
71
+
72
+ describe '#create_server' do
73
+ it 'creates a server' do
74
+ server = client.create_server(connection_string: 'rO0ABXQCmCI2MDA2MjQyNjI0MDI4MDE5MjEifHwiNjAwNjI0MTc0ODU5Mjg4ODMzInx8Im1vcmUtMDIifHwibWh3aGNza3I4bThocHcycyJ8fCIxMC4xMC40Ni45NDo0MjgyInx8Im51bGwifHwiMTAuMTAuNDYuOTQ6NDI4NiJ8fCIxMC4xMC40Ni45NDo0MjgzInx8Imh0dHA6Ly8xMC4xMC40Ni45NDo0MjgwInx8Ik1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBcFcxTVd0bnUyWEd0aXkzQjFWMXJlV1dXR204ak5OV3V1SHVDTGVNcHdqRGVHMUFUQm5aaTV5aEIxSTBBREhCekZYYkwrbHgvTTBMUDJuQkplek9nRVRXQ0R5ZCtncXV1K3pBdlF4K3RrdTZHcmo2cDZhaHgxYnQ2Y0tZd28zcW9jaTMxY3pZOElRWll5V0JVZUducDlEOTd3ZWxmaGgxakkwdEE3MlBUSEt0NzAvcUdDeXZaaVRqK3VSRDhIVTJsL3hDaVh2a2F6Wmc0dzBBQXhmL0VwNUlmNFJBYlNPTzZrTzNjVkFmcWxxcjdxS2dqc04ydGFhVlgvbXM0YnBmQ05ubXhHZWI3bnI1WXMrcUpuT0Q3bytTb1R5dmVJWm5SMUtkeEkwcDBIdmpLd3JSeEpIamdrS0Z6RU1lTFFhVmJlRmhrTm5RM3laVlVydkdOeDZXSHN3SURBUUFCInx8IlNUT1JBR0VfTk9ERSJ8fCJEZWZhdWx0Inx8Ii92YXIvb3B0L3Byb3NlcnZlci9iYWNrdXBBcmNoaXZlcyJ8fCJDcmFzaFBsYW5BcmNoaXZlX0RlZmF1bHQifHwibnVsbCI=', destination_id: 4)
75
+ server.should be_a(Code42::Server)
76
+
77
+ end
78
+ end
79
+
80
+ describe '#destination' do
81
+ it 'returns a destination' do
82
+ client.destination(45).should be_a(Code42::Destination)
83
+ end
84
+ end
85
+
86
+ describe '#product_licenses' do
87
+ it 'returns an array of product licenses' do
88
+ client.product_licenses.should be_an(Array)
89
+ client.product_licenses.first.should be_a(Code42::ProductLicense)
90
+ end
91
+ end
92
+
93
+ describe '#add_product_license' do
94
+ it 'adds a product license' do
95
+ product_licenses = client.add_product_license('ZP5Pbz8wx1dBHKjhkkQjGDZ+tTtkvuD5e5d2TC9/uHoODR9NvyaHfbypRUHR15hbeHdf7ExfnVpmwPiIcgYxCQ==')
96
+ product_licenses.first.license_key.should == 'ZP5Pbz8wx1dBHKjhkkQjGDZ+tTtkvuD5e5d2TC9/uHoODR9NvyaHfbypRUHR15hbeHdf7ExfnVpmwPiIcgYxCQ=='
97
+ end
98
+ end
99
+
100
+ describe '#remove_product_license' do
101
+ it 'removes a product license' do
102
+ product_licenses = client.product_licenses
103
+ id = product_licenses.first.id
104
+ client.remove_product_license id
105
+ client.product_licenses.should be_empty
106
+ end
107
+ end
108
+
109
+ describe '#apply_mlk' do
110
+ it 'applies the mlk' do
111
+ response = client.apply_mlk 'BdYS3i2U+1J/d/sU+IeZ/sTP0mac3k3FyXHxL69MPps3JOUIjb6PUc2UUw5jrD01CnLsJLhnanwJUTCRyjtwn+b7BkI/5kjosUo5RETbLKlc4PToufLu6cELvTUdwi/tMdLJFtx51jtoVdnZu4CfkBbcgcXR9yafkKas8XuOSd0=', {}
112
+ expect(response).to be_a Code42::Token
113
+ expect(response.cookie_token).to eql '1ix3k2701jn5l0kixl1xa05giw'
114
+ expect(response.url_token).to eql '136jc2w1tym050fdkky855t7en'
115
+ client.connection.mlk.should eql 'BdYS3i2U+1J/d/sU+IeZ/sTP0mac3k3FyXHxL69MPps3JOUIjb6PUc2UUw5jrD01CnLsJLhnanwJUTCRyjtwn+b7BkI/5kjosUo5RETbLKlc4PToufLu6cELvTUdwi/tMdLJFtx51jtoVdnZu4CfkBbcgcXR9yafkKas8XuOSd0='
116
+ end
117
+ end
118
+
119
+ describe '#validate_token' do
120
+ it 'returns a valid response' do
18
121
  token = client.get_token
19
122
  validation = client.validate_token token
20
123
  validation.should be_valid
21
124
  end
22
125
  end
23
126
 
24
- describe "#user_roles" do
25
- it "returns an enumerable" do
127
+ describe '#user_roles' do
128
+ it 'returns an enumerable' do
26
129
  roles = client.user_roles
27
130
  roles.should respond_to(:each)
28
131
  end
29
132
  end
30
133
 
31
- describe "#unassign_role" do
134
+ describe '#unassign_role' do
32
135
 
33
136
  let(:user_id) { 4 }
34
137
  let(:role_name) { 'PROe User' }
35
138
 
36
- it "removes the role" do
139
+ it 'removes the role' do
37
140
  current_roles = client.user_roles user_id
38
141
  current_role_names = current_roles.map(&:name)
39
142
 
@@ -47,50 +150,50 @@ describe Code42::Client, :vcr do
47
150
  end
48
151
  end
49
152
 
50
- describe "#permissions" do
51
- it "returns an enumerable of permissions" do
153
+ describe '#permissions' do
154
+ it 'returns an enumerable of permissions' do
52
155
  permissions = client.permissions
53
156
  permissions.should respond_to(:each)
54
157
  expect(permissions.first).to be_a Code42::Permission
55
158
  end
56
159
  end
57
160
 
58
- describe "#roles" do
59
- it "returns an enumerable" do
161
+ describe '#roles' do
162
+ it 'returns an enumerable' do
60
163
  roles = client.roles
61
164
  roles.should respond_to(:each)
62
165
  end
63
166
  end
64
167
 
65
- describe "#create_role" do
168
+ describe '#create_role' do
66
169
  it 'creates a role' do
67
170
  role = client.create_role('My Role', ['admin.user.read'])
68
171
  role.name.should == 'My Role'
69
172
  end
70
173
  end
71
174
 
72
- describe "#delete_role" do
73
- it "deletes a role" do
175
+ describe '#delete_role' do
176
+ it 'deletes a role' do
74
177
  client.delete_role(62)
75
178
  end
76
179
  end
77
180
 
78
- describe "#update_role" do
79
- it "updates a role" do
181
+ describe '#update_role' do
182
+ it 'updates a role' do
80
183
  role = client.update_role(63, name: 'New name')
81
184
  role.name.should == 'New name'
82
185
  end
83
186
  end
84
187
 
85
- describe "#get_token" do
86
- it "returns valid tokens" do
188
+ describe '#get_token' do
189
+ it 'returns valid tokens' do
87
190
  auth = client.get_token
88
191
  auth.cookie_token.should have(26).characters
89
192
  auth.url_token.should have(26).characters
90
193
  end
91
194
 
92
- context "when providing invalid credentials" do
93
- it "should raise an exception" do
195
+ context 'when providing invalid credentials' do
196
+ it 'should raise an exception' do
94
197
  client.settings.password = 'badpassword'
95
198
  expect{client.get_token}.to raise_error Code42::Error::AuthenticationError
96
199
  end
@@ -100,25 +203,25 @@ describe Code42::Client, :vcr do
100
203
  describe '#deactivate_org' do
101
204
  it 'puts to the correct route' do
102
205
  expect(client).to receive(:deactivate_org).with(88).and_call_original
103
- expect(client).to receive(:put).with("OrgDeactivation/88").and_call_original
206
+ expect(client).to receive(:put).with('OrgDeactivation/88', {}).and_call_original
104
207
  client.deactivate_org(88)
105
208
  end
106
209
  end
107
210
 
108
- describe "#create_org" do
211
+ describe '#create_org' do
109
212
  let(:org_attributes) do
110
213
  {
111
214
  :orgName => 'IBM'
112
215
  }
113
216
  end
114
217
 
115
- it "returns created org" do
218
+ it 'returns created org' do
116
219
  org = client.create_org(org_attributes)
117
220
  org.name.should eq 'IBM'
118
221
  end
119
222
  end
120
223
 
121
- describe "#create_user" do
224
+ describe '#create_user' do
122
225
  let(:user_attributes) do
123
226
  {
124
227
  :orgId => 2,
@@ -126,21 +229,22 @@ describe Code42::Client, :vcr do
126
229
  }
127
230
  end
128
231
 
129
- it "returns created user" do
232
+ it 'returns created user' do
130
233
  user = client.create_user(user_attributes)
131
234
  user.username.should eq 'testuser'
132
235
  user.id.should eq 38
236
+ user.org_id.should eq 2
133
237
  end
134
238
 
135
- context "when sending an invalid email" do
136
- it "raises an exception" do
239
+ context 'when sending an invalid email' do
240
+ it 'raises an exception' do
137
241
  user_attributes[:email] = 'testuser'
138
242
  expect { client.create_user(user_attributes) }.to raise_error Code42::Error::EmailInvalid
139
243
  end
140
244
  end
141
245
  end
142
246
 
143
- describe "#update_user" do
247
+ describe '#update_user' do
144
248
  let(:user_attributes) do
145
249
  {
146
250
  :orgId => 2,
@@ -154,54 +258,54 @@ describe Code42::Client, :vcr do
154
258
  @user = client.create_user(user_attributes)
155
259
  end
156
260
 
157
- it "returns the updated user" do
261
+ it 'returns the updated user' do
158
262
  updated_user = client.update_user(user.id, last_name: 'Jenkins')
159
263
  expect(updated_user.last_name).to eq 'Jenkins'
160
264
  end
161
265
 
162
- context "when sending an invalid email" do
163
- it "raises an exception" do
266
+ context 'when sending an invalid email' do
267
+ it 'raises an exception' do
164
268
  expect{ client.update_user(user.id, email: 'Jenkins') }.to raise_error(Code42::Error::EmailInvalid)
165
269
  end
166
270
  end
167
271
  end
168
272
 
169
- describe "#user" do
273
+ describe '#user' do
170
274
  let(:user_id) { 2 }
171
275
 
172
- context "when ID is not passed" do
173
- it "returns my user" do
276
+ context 'when ID is not passed' do
277
+ it 'returns my user' do
174
278
  user = client.user
175
279
  user.id.should == 1
176
280
  end
177
281
  end
178
282
 
179
- context "when ID is passed in" do
180
- it "returns a specific user" do
283
+ context 'when ID is passed in' do
284
+ it 'returns a specific user' do
181
285
  user = client.user(user_id)
182
286
  user.id.should == user_id
183
287
  end
184
288
 
185
- it "passes params to code42 server" do
289
+ it 'passes params to code42 server' do
186
290
  client.should_receive(:object_from_response).with(Code42::User, :get, "user/#{user_id}", :incAll => true)
187
- user = client.user(user_id, :incAll => true)
291
+ client.user(user_id, :incAll => true)
188
292
  end
189
293
  end
190
294
 
191
- context "when blocked" do
192
- it "returns the blocked status" do
295
+ context 'when blocked' do
296
+ it 'returns the blocked status' do
193
297
  client.block_user(user_id)
194
298
  user = client.user(user_id)
195
299
  user.blocked.should be_true
196
300
  end
197
301
  end
198
302
 
199
- context "when unblocked" do
303
+ context 'when unblocked' do
200
304
  before(:each) do
201
305
  client.block_user(user_id)
202
306
  end
203
307
 
204
- it "returns the blocked status" do
308
+ it 'returns the blocked status' do
205
309
  client.unblock_user(user_id)
206
310
  user = client.user(user_id)
207
311
  user.blocked.should be_false
@@ -209,41 +313,41 @@ describe Code42::Client, :vcr do
209
313
  end
210
314
  end
211
315
 
212
- describe "#org" do
213
- context "when ID is not passed" do
214
- it "returns my org" do
316
+ describe '#org' do
317
+ context 'when ID is not passed' do
318
+ it 'returns my org' do
215
319
  org = client.org
216
320
  org.id.should == 1
217
321
  end
218
322
  end
219
323
 
220
- context "when ID is passed in" do
221
- it "returns a specific org" do
324
+ context 'when ID is passed in' do
325
+ it 'returns a specific org' do
222
326
  org = client.org(1)
223
327
  org.id.should == 1
224
328
  end
225
329
 
226
- it "passes params to code42 server" do
227
- client.should_receive(:object_from_response).with(Code42::Org, :get, "org/2", :incAll => true)
228
- user = client.org(2, :incAll => true)
330
+ it 'passes params to code42 server' do
331
+ client.should_receive(:object_from_response).with(Code42::Org, :get, 'org/2', :incAll => true)
332
+ client.org(2, :incAll => true)
229
333
  end
230
334
  end
231
335
  end
232
336
 
233
- describe "#find_org_by_name" do
234
- it "returns the org with the specified name" do
337
+ describe '#find_org_by_name' do
338
+ it 'returns the org with the specified name' do
235
339
  org = client.find_org_by_name 'PROServer Demo'
236
340
  org.name.should == 'PROServer Demo'
237
341
  end
238
342
  end
239
343
 
240
- describe "#ping" do
241
- it "returns a ping" do
344
+ describe '#ping' do
345
+ it 'returns a ping' do
242
346
  client.ping.should be_true
243
347
  end
244
348
  end
245
349
 
246
- describe "#reset_password" do
350
+ describe '#reset_password' do
247
351
  shared_examples 'reset_password' do
248
352
  it 'is successful' do
249
353
  expect(client.reset_password(*arguments)).to be_true