ogre 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +20 -0
  4. data/.rubocop.yml +16 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +4 -0
  7. data/README.md +102 -0
  8. data/Rakefile +18 -0
  9. data/bin/ogre +4 -0
  10. data/lib/ogre.rb +44 -0
  11. data/lib/ogre/associate.rb +57 -0
  12. data/lib/ogre/base.rb +21 -0
  13. data/lib/ogre/config.rb +18 -0
  14. data/lib/ogre/messages.rb +84 -0
  15. data/lib/ogre/org-create.rb +96 -0
  16. data/lib/ogre/org-delete.rb +29 -0
  17. data/lib/ogre/runner.rb +40 -0
  18. data/lib/ogre/set-private-key.rb +57 -0
  19. data/lib/ogre/skeletons/code_generator/files/default/chefignore +95 -0
  20. data/lib/ogre/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
  21. data/lib/ogre/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
  22. data/lib/ogre/skeletons/code_generator/files/default/gitignore +16 -0
  23. data/lib/ogre/skeletons/code_generator/files/default/repo/README.md +66 -0
  24. data/lib/ogre/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
  25. data/lib/ogre/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +3 -0
  26. data/lib/ogre/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
  27. data/lib/ogre/skeletons/code_generator/files/default/repo/data_bags/README.md +58 -0
  28. data/lib/ogre/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
  29. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
  30. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/_default.json +9 -0
  31. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/dev.json +21 -0
  32. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
  33. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/int.json +21 -0
  34. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/prod.json +21 -0
  35. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/qa.json +21 -0
  36. data/lib/ogre/skeletons/code_generator/files/default/repo/environments/stage.json +21 -0
  37. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
  38. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/active-base.json +12 -0
  39. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
  40. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/loc_caeast.json +13 -0
  41. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/loc_canada.json +13 -0
  42. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/loc_cawest.json +13 -0
  43. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/loc_useast.json +13 -0
  44. data/lib/ogre/skeletons/code_generator/files/default/repo/roles/loc_uswest.json +13 -0
  45. data/lib/ogre/skeletons/code_generator/metadata.rb +8 -0
  46. data/lib/ogre/skeletons/code_generator/recipes/repo.rb +52 -0
  47. data/lib/ogre/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  48. data/lib/ogre/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
  49. data/lib/ogre/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  50. data/lib/ogre/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  51. data/lib/ogre/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  52. data/lib/ogre/skeletons/code_generator/templates/default/README.md.erb +4 -0
  53. data/lib/ogre/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
  54. data/lib/ogre/skeletons/code_generator/templates/default/knife.rb.erb +44 -0
  55. data/lib/ogre/skeletons/code_generator/templates/default/metadata.rb.erb +8 -0
  56. data/lib/ogre/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
  57. data/lib/ogre/user-create.rb +40 -0
  58. data/lib/ogre/user-delete.rb +39 -0
  59. data/lib/ogre/version.rb +5 -0
  60. data/ogre.gemspec +45 -0
  61. data/spec/fixtures/client_key/dummy.pem +27 -0
  62. data/spec/fixtures/vcr_cassettes/associate-no-org.yml +65 -0
  63. data/spec/fixtures/vcr_cassettes/associate-no-user.yml +65 -0
  64. data/spec/fixtures/vcr_cassettes/associate-user-exists.yml +135 -0
  65. data/spec/fixtures/vcr_cassettes/associate.yml +406 -0
  66. data/spec/fixtures/vcr_cassettes/org-create-exists.yml +69 -0
  67. data/spec/fixtures/vcr_cassettes/org-create.yml +71 -0
  68. data/spec/fixtures/vcr_cassettes/org-delete-no-org.yml +61 -0
  69. data/spec/fixtures/vcr_cassettes/org-delete.yml +68 -0
  70. data/spec/fixtures/vcr_cassettes/set-private-key.yml +239 -0
  71. data/spec/fixtures/vcr_cassettes/user-create-bad-email.yml +66 -0
  72. data/spec/fixtures/vcr_cassettes/user-create-exists.yml +70 -0
  73. data/spec/fixtures/vcr_cassettes/user-create-short-password.yml +66 -0
  74. data/spec/fixtures/vcr_cassettes/user-create.yml +72 -0
  75. data/spec/fixtures/vcr_cassettes/user-delete-not-found.yml +61 -0
  76. data/spec/fixtures/vcr_cassettes/user-delete.yml +136 -0
  77. data/spec/ogre/associate_spec.rb +67 -0
  78. data/spec/ogre/org-create_spec.rb +52 -0
  79. data/spec/ogre/org-delete_spec.rb +34 -0
  80. data/spec/ogre/set-private-key_spec.rb +16 -0
  81. data/spec/ogre/user-create_spec.rb +58 -0
  82. data/spec/ogre/user-delete_spec.rb +34 -0
  83. data/spec/spec_helper.rb +16 -0
  84. metadata +349 -0
@@ -0,0 +1,70 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://chef.server/users
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: '{"username":"user","first_name":"firstname","last_name":"lastname","display_name":"firstname
9
+ lastname","email":"user@exmaple.com","password":"password123"}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ Accept:
14
+ - application/json
15
+ Accept-Encoding:
16
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
17
+ X-Ops-Sign:
18
+ - algorithm=sha1;version=1.0;
19
+ X-Ops-Userid: pivotal
20
+ X-Ops-Timestamp:
21
+ - '2015-04-27T22:18:45Z'
22
+ X-Ops-Content-Hash:
23
+ - "{{X-Ops-Content-Hash}}"
24
+ X-Ops-Authorization-1:
25
+ - "{{X-Ops-Authorization-1}}"
26
+ X-Ops-Authorization-2:
27
+ - "{{X-Ops-Authorization-2}}"
28
+ X-Ops-Authorization-3:
29
+ - "{{X-Ops-Authorization-3}}"
30
+ X-Ops-Authorization-4:
31
+ - "{{X-Ops-Authorization-4}}"
32
+ X-Ops-Authorization-5:
33
+ - "{{X-Ops-Authorization-5}}"
34
+ X-Ops-Authorization-6:
35
+ - "{{X-Ops-Authorization-6}}"
36
+ Host:
37
+ - chef.server:443
38
+ X-Remote-Request-Id:
39
+ - 68285a19-c397-4f8f-86df-640a7754c69b
40
+ Content-Length:
41
+ - '155'
42
+ X-Chef-Version:
43
+ - 12.2.1
44
+ User-Agent:
45
+ - ruby
46
+ response:
47
+ status:
48
+ code: 409
49
+ message: Conflict
50
+ headers:
51
+ Server:
52
+ - ngx_openresty/1.4.3.6
53
+ Date:
54
+ - Mon, 27 Apr 2015 22:18:37 GMT
55
+ Content-Type:
56
+ - application/json
57
+ Content-Length:
58
+ - '40'
59
+ Connection:
60
+ - keep-alive
61
+ X-Ops-Api-Info:
62
+ - flavor=cs;version=12.0.0;oc_erchef=1.5.0
63
+ Location:
64
+ - http://chef.server/users/user
65
+ body:
66
+ encoding: UTF-8
67
+ string: '{"error":["User ''user'' already exists"]}'
68
+ http_version:
69
+ recorded_at: Mon, 27 Apr 2015 22:18:46 GMT
70
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://chef.server/users
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: '{"username":"user","first_name":"firstname","last_name":"lastname","display_name":"firstname
9
+ lastname","email":"user@exmaple.com","password":"a"}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ Accept:
14
+ - application/json
15
+ Accept-Encoding:
16
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
17
+ X-Ops-Sign:
18
+ - algorithm=sha1;version=1.0;
19
+ X-Ops-Userid: pivotal
20
+ X-Ops-Timestamp:
21
+ - '2015-04-28T17:39:21Z'
22
+ X-Ops-Content-Hash:
23
+ - "{{X-Ops-Content-Hash}}"
24
+ X-Ops-Authorization-1:
25
+ - "{{X-Ops-Authorization-1}}"
26
+ X-Ops-Authorization-2:
27
+ - "{{X-Ops-Authorization-2}}"
28
+ X-Ops-Authorization-3:
29
+ - "{{X-Ops-Authorization-3}}"
30
+ X-Ops-Authorization-4:
31
+ - "{{X-Ops-Authorization-4}}"
32
+ X-Ops-Authorization-5:
33
+ - "{{X-Ops-Authorization-5}}"
34
+ X-Ops-Authorization-6:
35
+ - "{{X-Ops-Authorization-6}}"
36
+ Host:
37
+ - chef.server:443
38
+ X-Remote-Request-Id:
39
+ - cd8acd59-0f29-459e-b6a7-1772e101c86b
40
+ Content-Length:
41
+ - '145'
42
+ X-Chef-Version:
43
+ - 12.2.1
44
+ User-Agent:
45
+ - ruby
46
+ response:
47
+ status:
48
+ code: 400
49
+ message: Bad Request
50
+ headers:
51
+ Server:
52
+ - ngx_openresty/1.4.3.6
53
+ Date:
54
+ - Tue, 28 Apr 2015 17:39:22 GMT
55
+ Content-Length:
56
+ - '54'
57
+ Connection:
58
+ - keep-alive
59
+ X-Ops-Api-Info:
60
+ - flavor=cs;version=12.0.0;oc_erchef=1.5.0
61
+ body:
62
+ encoding: UTF-8
63
+ string: '{"error":["Password must have at least 6 characters"]}'
64
+ http_version:
65
+ recorded_at: Tue, 28 Apr 2015 17:39:22 GMT
66
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,72 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://chef.server/users
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: '{"username":"user","first_name":"firstname","last_name":"lastname","display_name":"firstname
9
+ lastname","email":"user@exmaple.com","password":"password123"}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ Accept:
14
+ - application/json
15
+ Accept-Encoding:
16
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
17
+ X-Ops-Sign:
18
+ - algorithm=sha1;version=1.0;
19
+ X-Ops-Userid: pivotal
20
+ X-Ops-Timestamp:
21
+ - '2015-04-27T20:11:22Z'
22
+ X-Ops-Content-Hash:
23
+ - "{{X-Ops-Content-Hash}}"
24
+ X-Ops-Authorization-1:
25
+ - "{{X-Ops-Authorization-1}}"
26
+ X-Ops-Authorization-2:
27
+ - "{{X-Ops-Authorization-2}}"
28
+ X-Ops-Authorization-3:
29
+ - "{{X-Ops-Authorization-3}}"
30
+ X-Ops-Authorization-4:
31
+ - "{{X-Ops-Authorization-4}}"
32
+ X-Ops-Authorization-5:
33
+ - "{{X-Ops-Authorization-5}}"
34
+ X-Ops-Authorization-6:
35
+ - "{{X-Ops-Authorization-6}}"
36
+ Host:
37
+ - chef.server:443
38
+ X-Remote-Request-Id:
39
+ - 339c80ef-816f-4fbb-aa52-6cb7c85efb5d
40
+ Content-Length:
41
+ - '155'
42
+ X-Chef-Version:
43
+ - 12.2.1
44
+ User-Agent:
45
+ - ruby
46
+ response:
47
+ status:
48
+ code: 201
49
+ message: Created
50
+ headers:
51
+ Server:
52
+ - ngx_openresty/1.4.3.6
53
+ Date:
54
+ - Mon, 27 Apr 2015 20:11:14 GMT
55
+ Content-Type:
56
+ - application/json
57
+ Content-Length:
58
+ - '1761'
59
+ Connection:
60
+ - keep-alive
61
+ X-Ops-Api-Info:
62
+ - flavor=cs;version=12.0.0;oc_erchef=1.5.0
63
+ Location:
64
+ - https://chef.server/users/user
65
+ body:
66
+ encoding: UTF-8
67
+ string: '{"uri":"https://chef.server/users/user","private_key":"-----BEGIN
68
+ RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA0qwivShqlYZIzvcELoSiijCMJmBSfbyhjeiiM/sduYs3f4ME\neaAiQKaIyvIbrOeSRDl4aiyP7Dmf8QzmsNH3Xi1LURFIm42GZ0i4cdGhr9eJlXsQ\nDFd4j2aPafcFJXzepXbeOygkg4kU9vy53e3DkENcWQsrmUayiyl8pbQRIdIOZqT3\nMq5sWQas4ltrv66mSdjmGw389zs1QOeIsbAIqWlqdDWd3j53ifX59INhy6gX3uy8\nu0uI6SHzaYDUtuCvMshsIx+BB+DRMZHpA1oEj7xRuZ6ERQStIcbvG80qMqQWY8aU\nSHd3DhHNDnigtA3cPlYs8wj5Yyz3inhwEe4i2QIDAQABAoIBAQCsdS9m67v8tVXK\n3xl0Py2TtFQ2YimFNrKFqceGh+34YsfGwWkba4Q+qlVW1UTkkRkCco1pVRtoRG/y\n8x2x59/5H1kFfwGSHRPGXxhmTDZw7R9616f2gnB1635BP27eFk9o4lrf0Ge7qa8Y\n1SAOVcH+ybXCSsuhCOfF1ets9nAD3yU1l+u10enX17c8apkbiTBuvV1LduGha6Pj\ngyvLBBtJfChYYEjd3ulUflX2hV4/6kU6wo3PHMpPHMlr+/pCSPpI8YPxdzuczmAO\nWaU0bnzbMdGsPEc4NvSeuF8qNI/Sf0zAGXBTX54JkPZUL3OvzBr48+xvX9mGQELN\nPBdZJ3flAoGBAPOUdQt/dNDtq8FFYgZHQE+wj+5UV8IMoxGOpcReUuBDrFID9JNU\nQjMo556u6G61yClkUMPdl+VR6Tj6DSRgvgKO0U+P2RK//i+U/i71nRkfY0mFYq/Z\nGrMyE6Z7bvA4QYIqIXOrDLq5p3HPEbou6KS6WDWDyV/4XNn1m0ZA6XrrAoGBAN1q\nH8RQtFB/yP/pXu6dZ+ugOCgkwLaW312xB8AbRIFlvI1jDqGUJUKj6PVFgORfbcuS\nye5U4g6B1YkCthFMHRa1Ha1w78yVuOS1Z+tdWL6r97jkdHatkpAzVJpg0bF9wD9W\nptHAwvkY4g07xsZ1HP8IMuhHLbrDBRibYfVkjWBLAoGBAIwDwmQhl9yhQiGO6JID\nUwx7ycCN6wQ4j2QAQ3llXu5a+CsM6wHlZUhTMxEcKa+5/p0MdQCh2DaRpyaBVhyb\nH54IyniZj4YfptVjJ9mGhg9y43fXnKrIeXiYSINiYJrlO4K/BQugP2j2XzIkfWQw\norpOA3Z/krn/4h/H9sGjfpKRAoGAXPVgTvC/M4ji36agJ7hIWCHVUe1UR5SCRPi9\nU0dfdKA9EHNFQktLdXYRqWA75CW4mB6RzxEuM38JItPTkuGM2OrDgf0HgLJfhQ4w\nih2P08WpZKPtzaHEBey3GXWKtGUiYLVFpoyyjxiGV54AL3Qd72kGzoSLy3xzWEhs\nUTWdMY8CgYAn4AVpKGIQ5wc5socmybZPQ4h6Hlj83bQui+6PDJRfyrumeIneNEDK\nVOj83aGkdT05cDFH4d1p50mi4TMKWcqcVAprlo5qIJUEdTJodCkN6LLsJMVuHtzK\nZzQxmf32bxmg7DmPJIJQkGhS8ynwcXXJf92vdoAq7jPfskyMkWroXw==\n-----END
69
+ RSA PRIVATE KEY-----"}'
70
+ http_version:
71
+ recorded_at: Mon, 27 Apr 2015 20:11:24 GMT
72
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://chef.server/users/unknown/organizations
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ X-Ops-Sign:
15
+ - algorithm=sha1;version=1.0;
16
+ X-Ops-Userid: pivotal
17
+ X-Ops-Timestamp:
18
+ - '2015-04-29T19:51:29Z'
19
+ X-Ops-Content-Hash:
20
+ - "{{X-Ops-Content-Hash}}"
21
+ X-Ops-Authorization-1:
22
+ - "{{X-Ops-Authorization-1}}"
23
+ X-Ops-Authorization-2:
24
+ - "{{X-Ops-Authorization-2}}"
25
+ X-Ops-Authorization-3:
26
+ - "{{X-Ops-Authorization-3}}"
27
+ X-Ops-Authorization-4:
28
+ - "{{X-Ops-Authorization-4}}"
29
+ X-Ops-Authorization-5:
30
+ - "{{X-Ops-Authorization-5}}"
31
+ X-Ops-Authorization-6:
32
+ - "{{X-Ops-Authorization-6}}"
33
+ Host:
34
+ - chef.server:443
35
+ X-Remote-Request-Id:
36
+ - 0ed7d600-dc63-43f3-a5aa-e2c03c0d376a
37
+ X-Chef-Version:
38
+ - 12.3.0
39
+ User-Agent:
40
+ - Chef Client/12.3.0 (ruby-2.1.4-p265; ohai-8.2.0; x86_64-darwin12.0; +http://opscode.com)
41
+ response:
42
+ status:
43
+ code: 404
44
+ message: Object Not Found
45
+ headers:
46
+ Server:
47
+ - ngx_openresty/1.4.3.6
48
+ Date:
49
+ - Wed, 29 Apr 2015 19:51:29 GMT
50
+ Content-Length:
51
+ - '39'
52
+ Connection:
53
+ - keep-alive
54
+ X-Ops-Api-Info:
55
+ - flavor=cs;version=12.0.0;oc_erchef=1.5.0
56
+ body:
57
+ encoding: UTF-8
58
+ string: '{"error":"Could not find user unknown"}'
59
+ http_version:
60
+ recorded_at: Wed, 29 Apr 2015 19:51:29 GMT
61
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,136 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://chef.server/users/user/organizations
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ X-Ops-Sign:
15
+ - algorithm=sha1;version=1.0;
16
+ X-Ops-Userid: pivotal
17
+ X-Ops-Timestamp:
18
+ - '2015-04-27T20:22:32Z'
19
+ X-Ops-Content-Hash:
20
+ - "{{X-Ops-Content-Hash}}"
21
+ X-Ops-Authorization-1:
22
+ - "{{X-Ops-Authorization-1}}"
23
+ X-Ops-Authorization-2:
24
+ - "{{X-Ops-Authorization-2}}"
25
+ X-Ops-Authorization-3:
26
+ - "{{X-Ops-Authorization-3}}"
27
+ X-Ops-Authorization-4:
28
+ - "{{X-Ops-Authorization-4}}"
29
+ X-Ops-Authorization-5:
30
+ - "{{X-Ops-Authorization-5}}"
31
+ X-Ops-Authorization-6:
32
+ - "{{X-Ops-Authorization-6}}"
33
+ Host:
34
+ - chef.server:443
35
+ X-Remote-Request-Id:
36
+ - 71cc9890-ffcb-4597-a996-55e560753739
37
+ X-Chef-Version:
38
+ - 12.2.1
39
+ User-Agent:
40
+ - ruby
41
+ response:
42
+ status:
43
+ code: 200
44
+ message: OK
45
+ headers:
46
+ Server:
47
+ - ngx_openresty/1.4.3.6
48
+ Date:
49
+ - Mon, 27 Apr 2015 20:22:23 GMT
50
+ Content-Type:
51
+ - application/json
52
+ Content-Length:
53
+ - '2'
54
+ Connection:
55
+ - keep-alive
56
+ X-Ops-Api-Info:
57
+ - flavor=cs;version=12.0.0;oc_erchef=1.5.0
58
+ body:
59
+ encoding: UTF-8
60
+ string: "[]"
61
+ http_version:
62
+ recorded_at: Mon, 27 Apr 2015 20:22:32 GMT
63
+ - request:
64
+ method: delete
65
+ uri: https://chef.server/users/user
66
+ body:
67
+ encoding: US-ASCII
68
+ string: ''
69
+ headers:
70
+ Accept:
71
+ - application/json
72
+ Accept-Encoding:
73
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
74
+ X-Ops-Sign:
75
+ - algorithm=sha1;version=1.0;
76
+ X-Ops-Userid: pivotal
77
+ X-Ops-Timestamp:
78
+ - '2015-04-27T20:22:32Z'
79
+ X-Ops-Content-Hash:
80
+ - "{{X-Ops-Content-Hash}}"
81
+ X-Ops-Authorization-1:
82
+ - "{{X-Ops-Authorization-1}}"
83
+ X-Ops-Authorization-2:
84
+ - "{{X-Ops-Authorization-2}}"
85
+ X-Ops-Authorization-3:
86
+ - "{{X-Ops-Authorization-3}}"
87
+ X-Ops-Authorization-4:
88
+ - "{{X-Ops-Authorization-4}}"
89
+ X-Ops-Authorization-5:
90
+ - "{{X-Ops-Authorization-5}}"
91
+ X-Ops-Authorization-6:
92
+ - "{{X-Ops-Authorization-6}}"
93
+ Host:
94
+ - chef.server:443
95
+ X-Remote-Request-Id:
96
+ - 71cc9890-ffcb-4597-a996-55e560753739
97
+ X-Chef-Version:
98
+ - 12.2.1
99
+ User-Agent:
100
+ - ruby
101
+ response:
102
+ status:
103
+ code: 200
104
+ message: OK
105
+ headers:
106
+ Server:
107
+ - ngx_openresty/1.4.3.6
108
+ Date:
109
+ - Mon, 27 Apr 2015 20:22:23 GMT
110
+ Content-Type:
111
+ - application/json
112
+ Transfer-Encoding:
113
+ - chunked
114
+ Connection:
115
+ - keep-alive
116
+ X-Ops-Api-Info:
117
+ - flavor=cs;version=12.0.0;oc_erchef=1.5.0
118
+ Content-Encoding:
119
+ - gzip
120
+ body:
121
+ encoding: ASCII-8BIT
122
+ string: !binary |-
123
+ H4sIAAAAAAAAA2WSzZKiMBhFX8Vy2/OjgjbOaoIgRgUNDCVYVHUFCBAICERQ
124
+ 6Jp3H3R6ZtNZnbr3rHK/93HDSV3gnIx/PHH8ZVw2PqPBW0a6Ifv6eLKqQWN0
125
+ tOU9XI12qvsMvUKHUIYpMOQ4q5KMasvbRAZIXQNwWAEkgUe/incDq2BS3Whr
126
+ JRVzz7BvA3V/sahX0HSlb3PZivwuSQml+nceNi4XIlFXCQYU7TDsWujXB2KZ
127
+ ChMx7Y6vSh5JqM+5sRG8wqHTvW2uYS7OtPOEikGoJfWSbJnDkbIOxXSGjzgK
128
+ 1lunJ6Xjk0MXZ7GY2cu2mwtEULwiU43ghHid27ijHZNKH5kwhIdz9UvQqzk/
129
+ IcxFdq3bxSK3wjTXboK07PkUHQjkPoBeUZ1YFSqnUEjnAo2c+RIaSbeIHaHp
130
+ pGbSwIW16bGr2Ndm1eo84fD+IssviqmfNyWYXlSvSF/vZnNeqCayrjDwW02a
131
+ VHqFTq6EbWsTCkqyMZSCxlcgBEfmcumWzt2uF2iR3FQiDj85Q1ABCMhe8RxH
132
+ NZTPe3nFsC7JMWUfY/8k9xyXjHwLLvlQhZSXDHdvH+cQ0ZpfHzxi+C8MzjP8
133
+ ZAzFw/mX//d//wHj/2E7YAIAAA==
134
+ http_version:
135
+ recorded_at: Mon, 27 Apr 2015 20:22:32 GMT
136
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,67 @@
1
+ require_relative '../spec_helper.rb'
2
+ require 'ogre'
3
+
4
+ VCR.configure do |config|
5
+ config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
6
+ config.hook_into :webmock
7
+
8
+ # remove sensitive authentication information from the recording
9
+ config.before_record do |interaction|
10
+ headers = interaction.request.headers
11
+ headers.keys
12
+ .select { |k| k =~ /^X-Ops-(Authorization-|Content-Hash)/ }
13
+ .each { |header| headers[header] = Array("{{#{header}}}") }
14
+ headers['X-Ops-Userid'] = 'pivotal'
15
+ end
16
+ end
17
+
18
+ describe Ogre::Associate do
19
+ it 'should associate user to org' do
20
+ args = %w(my-org-name test) + DEFAULTS
21
+ VCR.use_cassette('associate', match_requests_on: [:uri]) do
22
+ response = "Successfully added 'test' to 'users' in the my-org-name org\n"
23
+ expect { Ogre::Associate.start(args) }.to output(response).to_stdout
24
+ end
25
+ end
26
+
27
+ it 'should associate user to users and admin group' do
28
+ args = %w(my-org-name test -a) + DEFAULTS
29
+ response = "Successfully added 'test' to 'users' in the my-org-name org\n" \
30
+ "Successfully added 'test' to 'admins' in the my-org-name org\n"
31
+ VCR.use_cassette('associate', match_requests_on: [:uri]) do
32
+ expect { Ogre::Associate.start(args) }.to output(response).to_stdout
33
+ end
34
+ end
35
+
36
+ it 'should fail user already exists' do
37
+ args = %w(my-org-name test) + DEFAULTS
38
+ response = "User 'test' already associated with organization 'my-org-name'\n"
39
+ VCR.use_cassette('associate-user-exists', match_requests_on: [:uri]) do
40
+ expect { Ogre::Associate.start(args) }.to output(response).to_stdout
41
+ end
42
+ end
43
+
44
+ it 'should fail org does not exist' do
45
+ args = %w(non-existent-org test) + DEFAULTS
46
+ VCR.use_cassette('associate-no-org', match_requests_on: [:uri]) do
47
+ begin
48
+ Ogre::Associate.start(args)
49
+ rescue Net::HTTPServerException => e
50
+ response = JSON.parse(e.response.body)
51
+ expect(response['error']).to eq(["organization 'non-existent-org' does not exist."])
52
+ end
53
+ end
54
+ end
55
+
56
+ it 'should fail user does not exist' do
57
+ args = %w(my-org-name non-existent-user) + DEFAULTS
58
+ VCR.use_cassette('associate-no-user', match_requests_on: [:uri]) do
59
+ begin
60
+ Ogre::Associate.start(args)
61
+ rescue Net::HTTPServerException => e
62
+ response = JSON.parse(e.response.body)
63
+ expect(response['error']).to eq('Could not find user non-existent-user')
64
+ end
65
+ end
66
+ end
67
+ end