virtengine_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +21 -0
  6. data/README.md +27 -0
  7. data/Rakefile +10 -0
  8. data/lib/megam/api.rb +329 -0
  9. data/lib/megam/api/accounts.rb +96 -0
  10. data/lib/megam/api/addons.rb +27 -0
  11. data/lib/megam/api/assemblies.rb +49 -0
  12. data/lib/megam/api/assembly.rb +56 -0
  13. data/lib/megam/api/backups.rb +57 -0
  14. data/lib/megam/api/balances.rb +45 -0
  15. data/lib/megam/api/billedhistories.rb +35 -0
  16. data/lib/megam/api/billingtransactions.rb +25 -0
  17. data/lib/megam/api/components.rb +24 -0
  18. data/lib/megam/api/credits.rb +34 -0
  19. data/lib/megam/api/disks.rb +44 -0
  20. data/lib/megam/api/domains.rb +25 -0
  21. data/lib/megam/api/errors.rb +29 -0
  22. data/lib/megam/api/eventsall.rb +36 -0
  23. data/lib/megam/api/eventsbilling.rb +35 -0
  24. data/lib/megam/api/eventscontainer.rb +35 -0
  25. data/lib/megam/api/eventsmarketplace.rb +35 -0
  26. data/lib/megam/api/eventsstorage.rb +24 -0
  27. data/lib/megam/api/eventsvm.rb +35 -0
  28. data/lib/megam/api/flavors.rb +56 -0
  29. data/lib/megam/api/license.rb +26 -0
  30. data/lib/megam/api/marketplaces.rb +68 -0
  31. data/lib/megam/api/organizations.rb +50 -0
  32. data/lib/megam/api/promos.rb +18 -0
  33. data/lib/megam/api/quotas.rb +47 -0
  34. data/lib/megam/api/rawimages.rb +36 -0
  35. data/lib/megam/api/reports.rb +24 -0
  36. data/lib/megam/api/requests.rb +36 -0
  37. data/lib/megam/api/sensors.rb +35 -0
  38. data/lib/megam/api/snapshots.rb +46 -0
  39. data/lib/megam/api/sshkeys.rb +35 -0
  40. data/lib/megam/api/subscriptions.rb +26 -0
  41. data/lib/megam/api/version.rb +6 -0
  42. data/lib/megam/core/account.rb +245 -0
  43. data/lib/megam/core/account_collection.rb +122 -0
  44. data/lib/megam/core/addons.rb +169 -0
  45. data/lib/megam/core/addons_collection.rb +121 -0
  46. data/lib/megam/core/assemblies.rb +191 -0
  47. data/lib/megam/core/assemblies_collection.rb +122 -0
  48. data/lib/megam/core/assembly.rb +226 -0
  49. data/lib/megam/core/assembly_collection.rb +122 -0
  50. data/lib/megam/core/backups.rb +259 -0
  51. data/lib/megam/core/backups_collection.rb +122 -0
  52. data/lib/megam/core/balances.rb +187 -0
  53. data/lib/megam/core/balances_collection.rb +121 -0
  54. data/lib/megam/core/billedhistories.rb +190 -0
  55. data/lib/megam/core/billedhistories_collection.rb +121 -0
  56. data/lib/megam/core/billingtransactions.rb +214 -0
  57. data/lib/megam/core/billingtransactions_collection.rb +122 -0
  58. data/lib/megam/core/components.rb +326 -0
  59. data/lib/megam/core/components_collection.rb +123 -0
  60. data/lib/megam/core/credits.rb +146 -0
  61. data/lib/megam/core/credits_collection.rb +121 -0
  62. data/lib/megam/core/disks.rb +199 -0
  63. data/lib/megam/core/disks_collection.rb +122 -0
  64. data/lib/megam/core/domain_collection.rb +122 -0
  65. data/lib/megam/core/domains.rb +118 -0
  66. data/lib/megam/core/error.rb +70 -0
  67. data/lib/megam/core/eventsall.rb +186 -0
  68. data/lib/megam/core/eventsall_collection.rb +122 -0
  69. data/lib/megam/core/eventsbilling.rb +174 -0
  70. data/lib/megam/core/eventsbilling_collection.rb +122 -0
  71. data/lib/megam/core/eventscontainer.rb +187 -0
  72. data/lib/megam/core/eventscontainer_collection.rb +122 -0
  73. data/lib/megam/core/eventsmarketplace.rb +187 -0
  74. data/lib/megam/core/eventsmarketplace_collection.rb +122 -0
  75. data/lib/megam/core/eventsstorage.rb +156 -0
  76. data/lib/megam/core/eventsstorage_collection.rb +122 -0
  77. data/lib/megam/core/eventsvm.rb +187 -0
  78. data/lib/megam/core/eventsvm_collection.rb +122 -0
  79. data/lib/megam/core/flavors.rb +294 -0
  80. data/lib/megam/core/flavors_collection.rb +121 -0
  81. data/lib/megam/core/json_compat.rb +289 -0
  82. data/lib/megam/core/konipai.rb +42 -0
  83. data/lib/megam/core/license.rb +101 -0
  84. data/lib/megam/core/license_collection.rb +122 -0
  85. data/lib/megam/core/log.rb +19 -0
  86. data/lib/megam/core/marketplace.rb +308 -0
  87. data/lib/megam/core/marketplace_collection.rb +123 -0
  88. data/lib/megam/core/monologger.rb +89 -0
  89. data/lib/megam/core/organizations.rb +142 -0
  90. data/lib/megam/core/organizations_collection.rb +121 -0
  91. data/lib/megam/core/promos.rb +145 -0
  92. data/lib/megam/core/quotas.rb +215 -0
  93. data/lib/megam/core/quotas_collection.rb +121 -0
  94. data/lib/megam/core/rawimages.rb +194 -0
  95. data/lib/megam/core/rawimages_collection.rb +121 -0
  96. data/lib/megam/core/reports.rb +176 -0
  97. data/lib/megam/core/reports_collection.rb +121 -0
  98. data/lib/megam/core/request.rb +197 -0
  99. data/lib/megam/core/request_collection.rb +121 -0
  100. data/lib/megam/core/rest_adapter.rb +44 -0
  101. data/lib/megam/core/sensors.rb +141 -0
  102. data/lib/megam/core/sensors_collection.rb +121 -0
  103. data/lib/megam/core/snapshots.rb +268 -0
  104. data/lib/megam/core/snapshots_collection.rb +122 -0
  105. data/lib/megam/core/sshkey.rb +173 -0
  106. data/lib/megam/core/sshkey_collection.rb +122 -0
  107. data/lib/megam/core/stuff.rb +22 -0
  108. data/lib/megam/core/subscriptions.rb +167 -0
  109. data/lib/megam/core/subscriptions_collection.rb +121 -0
  110. data/lib/megam/core/text.rb +87 -0
  111. data/lib/megam/core/text_formatter.rb +64 -0
  112. data/lib/megam/mixins/assemblies.rb +16 -0
  113. data/lib/megam/mixins/assembly.rb +59 -0
  114. data/lib/megam/mixins/common_deployable.rb +78 -0
  115. data/lib/megam/mixins/components.rb +182 -0
  116. data/lib/megam/mixins/megam_attributes.rb +30 -0
  117. data/lib/megam/mixins/outputs.rb +23 -0
  118. data/lib/megam/mixins/policies.rb +27 -0
  119. data/lib/megam_api.rb +1 -0
  120. data/megam_api.gemspec +26 -0
  121. data/test/mixins/test_assemblies.rb +113 -0
  122. data/test/mixins/test_assembly.rb +74 -0
  123. data/test/mixins/test_component.rb +19 -0
  124. data/test/test_accounts.rb +127 -0
  125. data/test/test_addons.rb +26 -0
  126. data/test/test_assemblies.rb +88 -0
  127. data/test/test_assembly.rb +37 -0
  128. data/test/test_backups.rb +29 -0
  129. data/test/test_balances.rb +38 -0
  130. data/test/test_billedhistories.rb +30 -0
  131. data/test/test_billingtranscations.rb +35 -0
  132. data/test/test_components.rb +42 -0
  133. data/test/test_credits.rb +28 -0
  134. data/test/test_disks.rb +25 -0
  135. data/test/test_domains.rb +29 -0
  136. data/test/test_eventsbilling.rb +30 -0
  137. data/test/test_eventscontainer.rb +26 -0
  138. data/test/test_eventsstorage.rb +12 -0
  139. data/test/test_eventsvm.rb +26 -0
  140. data/test/test_helper.rb +77 -0
  141. data/test/test_marketplaces.rb +38 -0
  142. data/test/test_organizations.rb +45 -0
  143. data/test/test_promos.rb +11 -0
  144. data/test/test_quotas.rb +33 -0
  145. data/test/test_reports.rb +32 -0
  146. data/test/test_requests.rb +95 -0
  147. data/test/test_sensors.rb +50 -0
  148. data/test/test_snapshots.rb +30 -0
  149. data/test/test_sshkeys.rb +50 -0
  150. data/test/test_subscriptions.rb +22 -0
  151. metadata +325 -0
@@ -0,0 +1,30 @@
1
+ module Nilavu
2
+ module MegamAttributes
3
+ ATTRIBUTES = []
4
+ KEY = 'key'.freeze
5
+ VALUE = 'value'.freeze
6
+
7
+ attr_accessor *ATTRIBUTES
8
+
9
+ def attributes
10
+ NotImplementedError
11
+ end
12
+
13
+ def initialize(control_data = {})
14
+ set_attributes(control_data)
15
+ end
16
+
17
+ def set_attributes(control_data)
18
+ attributes.each { |a| instance_variable_set("@#{a}", control_data[a]) unless control_data[a].nil? }
19
+ end
20
+
21
+ def to_hash
22
+ h = attributes.reduce([]) do |res, key|
23
+ val = instance_variable_get("@#{key}".to_sym)
24
+ res << { KEY => key.to_s, VALUE => val } unless val.nil?
25
+ res
26
+ end
27
+ h
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/megam_attributes")
2
+
3
+ module Megam
4
+ class Outputs
5
+ include Nilavu::MegamAttributes
6
+
7
+ attr_reader :nodeip, :publicip, :privateip, :lastsuccessfulupdate, :laststatus
8
+
9
+ ATTRIBUTES = []
10
+
11
+ def attributes
12
+ ATTRIBUTES
13
+ end
14
+
15
+ def initialize(params)
16
+ set_attributes(params)
17
+ end
18
+
19
+ def to_array
20
+ array = []
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ module Megam
2
+ class Mixins
3
+ class Policies
4
+ attr_reader :bind_type, :policymembers
5
+
6
+ def initialize(params)
7
+ @bind_type = params[:bind_type] if params.key?(:bind_type)
8
+ @policymembers = params[:policymembers] if params.key?(:policymembers)
9
+ end
10
+
11
+ def to_array
12
+ com = []
13
+ if @bind_type && @bind_type != 'Unbound service'
14
+ value = {
15
+ name: 'bind policy',
16
+ ptype: 'colocated',
17
+ members: [
18
+ @policymembers
19
+ ]
20
+ }
21
+ com << value
22
+ end
23
+ com
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/megam_api.rb ADDED
@@ -0,0 +1 @@
1
+ require(File.join(File.dirname(__FILE__), "megam", "api"))
data/megam_api.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "megam/api/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "megam_api"
7
+ s.version = Megam::API::VERSION
8
+ s.authors = ["Rajthilak, Kishorekumar Neelamegam, Ranjitha R, Vinodhini V, Rathish VBR, Rajesh Rajagopalan, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan, Arunkumar sekar"]
9
+ s.email = ["rajthilak@megam.io","nkishore@megam.io","ranjithar@megam.io","vino.v@megam.io","rathishvbr@megam.io","rajeshr@megam.io","thomasalrin@gmail.com","morpheyesh@gmail.com","subash.avc@gmail.com","arunkumar.sekar@megam.io"]
10
+ s.homepage = "http://github.com/megamsys/megam_api"
11
+ s.license = "MIT"
12
+ s.extra_rdoc_files = ["README.md", "LICENSE" ]
13
+ s.summary = %q{Ruby Client for the Megam Vertice}
14
+ s.description = %q{Ruby Client for the Megam vertice. Performs REST calls to Vertice Gateway - http://github.com/megamsys/vertice_gateway.git}
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ s.add_runtime_dependency 'excon', '~> 0.52.0'
20
+ s.add_runtime_dependency 'highline', '~> 1.7'
21
+ s.add_runtime_dependency 'ffi-yajl', '~> 2.3'
22
+ s.add_runtime_dependency 'mixlib-config', '~> 2.2'
23
+ s.add_runtime_dependency 'mixlib-log', '~> 1.6'
24
+ s.add_development_dependency 'minitest', '~> 5.9'
25
+ s.add_development_dependency 'rake', '~> 11.2'
26
+ end
@@ -0,0 +1,113 @@
1
+ #require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
2
+
3
+ gem 'minitest' # ensure we are using the gem version
4
+ require 'minitest/autorun'
5
+
6
+ require File.expand_path("#{File.dirname(__FILE__)}/../../lib/megam/mixins/assemblies")
7
+ require File.expand_path("#{File.dirname(__FILE__)}/../../lib/megam/mixins/components")
8
+ class TestMixinsAssemblies < MiniTest::Unit::TestCase
9
+
10
+ def test_torpedo
11
+ ## input the torpedo hash
12
+ tmp_hash = {"utf8"=>"✓", "mkp_name" => "ubuntu", "cattype":"TORPEDO", "version":"14.04", "assemblyname"=>"biblical", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "SSH_USEOLD_name"=>"tom", "SSH_NEW_name"=>"", "sshoption"=>"SSH_USEOLD", "provider"=>"one", "componentname"=>"ovid", "commit"=>" Create ", "controller"=>"marketplaces", "action"=>"create", "email"=>"8@8.com", "api_key"=>"-NQi-aSKHcmKntCsXb03jw==", "host"=>"192.168.1.105", "org_id"=>"ORG1270367691894554624", "ssh_keypair_name"=>"tom", "name"=>"tom", "path"=>"8@8.com_tom"}
13
+
14
+ envs_hash = {"utf8"=>"✓", "authenticity_token"=>"EXNN8YBO01ebNv8RSbc3psdo+soP5Cxee8UXdi0qEdm78hkwKVIBaPzPh0IQBXcNtL6efvSkCbMkT1nca80zkA==", "version"=>"1.5.0", "mkp_name"=>"HotelManangement", "cattype"=>"ANALYTICS", "envs"=>[{"key":"spark_master","value":"<spark_master>"},{"key":"oja_assembly_id","value":"<oja_assembly_id>"},{"key":"file2","value":"<file2>"},{"key":"oja_email","value":"<oja_email>"},{"key":"oja_component_id","value":"<oja_component_id>"},{"key":"file1","value":"<file1>"},{"key":"oja_apikey","value":"<oja_apikey>"}], "assemblyname"=>"sweet", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "SSH_USEOLD_name"=>"megam_sss", "SSH_NEW_name"=>"", "sshoption"=>"SSH_USEOLD", "provider"=>"one", "componentname"=>"minute", "commit"=>" Create "}
15
+
16
+ #{"utf8"=>"✓", "version"=>"14.04", "mkp_name"=>"ubuntu", "cattype"=>"TORPEDO", "assemblyname"=>"implanting", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "SSH_USEOLD_name"=>"tom", "SSH_NEW_name"=>"", "sshoption"=>"SSH_USEOLD", "provider"=>"one", "componentname"=>"sad", "commit"=>" Create "}
17
+
18
+ #assemblies: [{"status"=>"launching", "tosca_type"=>"tosca.torpedo.ubuntu", "inputs"=>[{"key"=>"domain", "value"=>"megambox.com"}, {"key"=>"provider", "value"=>"one"}, {"key"=>"cpu", "value"=>"0.5"}, {"key"=>"ram", "value"=>"896"}, {"key"=>"version", "value"=>"14.04"}], "name"=>"implanting", "components"=>[], "outputs"=>[], "policies"=>[]}]
19
+
20
+ assembly_array = Megam::Mixins::Assemblies.new(envs_hash).to_hash
21
+ puts "=========================================> END <==============================================="
22
+ puts assembly_array.inspect
23
+
24
+ #response = megams.post_billings(tmp_hash)
25
+ #assert_equal(201, response.status)
26
+ end
27
+
28
+ =begin
29
+ def test_app_starterpack
30
+ ## input the torpedo hash
31
+ tmp_hash = {"utf8"=>"✓", "version"=>"8.x", "mkp_name"=>"Java", "cattype"=>"APP", "componentname"=>"marine", "sshoption"=>"SSH_NEW", "scm_name"=>"", "type"=>"source", "provider"=>"one", "assemblyname"=>"umiak", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "radio_app_scm"=>"starter_pack", "source"=>"https://github.com/megamsys/java-spring-petclinic.git", "check_ci"=>"true", "starterpack_git"=>"https://github.com/megamsys/java-spring-petclinic.git", "SSH_NEW_name"=>"tom", "commit"=>" Create "}
32
+
33
+
34
+
35
+ assembly_array = Megam::Mixins::Assemblies.new(tmp_hash).to_hash
36
+ puts "=========================================> END <==============================================="
37
+ puts assembly_array.inspect
38
+
39
+ end
40
+ =begin
41
+ def test_app_git
42
+ ## input the torpedo hash
43
+ tmp_hash = { :accounts_id => "ACT93476985797",
44
+ :line1 => "paypal",
45
+ :line2 => "#kjbh76",
46
+ :country_code => "",
47
+ :postal_code => "",
48
+ :state => "",
49
+ :phone => "",
50
+ :bill_type => ""
51
+ }
52
+
53
+ # comp_dable
54
+ # compare the results
55
+ response = megams.post_billings(tmp_hash)
56
+ assert_equal(201, response.status)
57
+ end
58
+
59
+ def test_app_oneclick
60
+ ## input the torpedo hash
61
+ tmp_hash = { :accounts_id => "ACT93476985797",
62
+ :line1 => "paypal",
63
+ :line2 => "#kjbh76",
64
+ :country_code => "",
65
+ :postal_code => "",
66
+ :state => "",
67
+ :phone => "",
68
+ :bill_type => ""
69
+ }
70
+
71
+ # comp_dable
72
+ # compare the results
73
+ response = megams.post_billings(tmp_hash)
74
+ assert_equal(201, response.status)
75
+ end
76
+
77
+ def test_service
78
+ ## input the torpedo hash
79
+ tmp_hash = { :accounts_id => "ACT93476985797",
80
+ :line1 => "paypal",
81
+ :line2 => "#kjbh76",
82
+ :country_code => "",
83
+ :postal_code => "",
84
+ :state => "",
85
+ :phone => "",
86
+ :bill_type => ""
87
+ }
88
+
89
+ # comp_dable
90
+ # compare the results
91
+ response = megams.post_billings(tmp_hash)
92
+ assert_equal(201, response.status)
93
+ end
94
+
95
+ def test_microservice
96
+ ## input the torpedo hash
97
+ tmp_hash = { :accounts_id => "ACT93476985797",
98
+ :line1 => "paypal",
99
+ :line2 => "#kjbh76",
100
+ :country_code => "",
101
+ :postal_code => "",
102
+ :state => "",
103
+ :phone => "",
104
+ :bill_type => ""
105
+ }
106
+
107
+ # comp_dable
108
+ # compare the results
109
+ response = megams.post_billings(tmp_hash)
110
+ assert_equal(201, response.status)
111
+ end
112
+ =end
113
+ end
@@ -0,0 +1,74 @@
1
+ class TestMixinsAssembly < MiniTest::Unit::TestCase
2
+
3
+ def test_torpedo
4
+ ## input the torpedo hash
5
+ tmp_hash = { :accounts_id => "ACT93476985797",
6
+ :line1 => "paypal",
7
+ :line2 => "#kjbh76",
8
+ :country_code => "",
9
+ :postal_code => "",
10
+ :state => "",
11
+ :phone => "",
12
+ :bill_type => ""
13
+ }
14
+
15
+ # comp_dable
16
+ # compare the results
17
+ response = megams.post_billings(tmp_hash)
18
+ assert_equal(201, response.status)
19
+ end
20
+
21
+ def test_app
22
+ ## input the torpedo hash
23
+ tmp_hash = { :accounts_id => "ACT93476985797",
24
+ :line1 => "paypal",
25
+ :line2 => "#kjbh76",
26
+ :country_code => "",
27
+ :postal_code => "",
28
+ :state => "",
29
+ :phone => "",
30
+ :bill_type => ""
31
+ }
32
+
33
+ # comp_dable
34
+ # compare the results
35
+ response = megams.post_billings(tmp_hash)
36
+ assert_equal(201, response.status)
37
+ end
38
+
39
+ def test_service
40
+ ## input the torpedo hash
41
+ tmp_hash = { :accounts_id => "ACT93476985797",
42
+ :line1 => "paypal",
43
+ :line2 => "#kjbh76",
44
+ :country_code => "",
45
+ :postal_code => "",
46
+ :state => "",
47
+ :phone => "",
48
+ :bill_type => ""
49
+ }
50
+
51
+ # comp_dable
52
+ # compare the results
53
+ response = megams.post_billings(tmp_hash)
54
+ assert_equal(201, response.status)
55
+ end
56
+
57
+ def test_microservice
58
+ ## input the torpedo hash
59
+ tmp_hash = { :accounts_id => "ACT93476985797",
60
+ :line1 => "paypal",
61
+ :line2 => "#kjbh76",
62
+ :country_code => "",
63
+ :postal_code => "",
64
+ :state => "",
65
+ :phone => "",
66
+ :bill_type => ""
67
+ }
68
+
69
+ # comp_dable
70
+ # compare the results
71
+ response = megams.post_billings(tmp_hash)
72
+ assert_equal(201, response.status)
73
+ end
74
+ end
@@ -0,0 +1,19 @@
1
+ gem 'minitest' # ensure we are using the gem version
2
+ require 'minitest/autorun'
3
+
4
+ require File.expand_path("#{File.dirname(__FILE__)}/../../lib/megam/mixins/components")
5
+
6
+ class TestMixinsComponent < MiniTest::Unit::TestCase
7
+
8
+ def test_app_starterpack
9
+ ## input the torpedo hash
10
+ tmp_hash = {"utf8"=>"✓", "version"=>"8.x", "mkp_name"=>"Java", "cattype"=>"APP", "componentname"=>"marine", "sshoption"=>"SSH_NEW", "scm_name"=>"", "type"=>"source", "provider"=>"one", "assemblyname"=>"umiak", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "radio_app_scm"=>"starter_pack", "source"=>"https://github.com/megamsys/java-spring-petclinic.git", "check_ci"=>"true", "starterpack_git"=>"https://github.com/megamsys/java-spring-petclinic.git", "SSH_NEW_name"=>"tom", "commit"=>" Create "}
11
+
12
+ tmp_hash = Hash[tmp_hash.map{ |k, v| [k.to_sym, v] }]
13
+ assembly_array = Megam::Mixins::Components.new(tmp_hash).to_hash
14
+ puts "=========================================> END <==============================================="
15
+ puts assembly_array.inspect
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,127 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestAccounts < MiniTest::Unit::TestCase
4
+
5
+ $admin = "admin-tom"
6
+ $normal = "normal-tom"
7
+ $tom_email = "tom@gomegam.com"
8
+ $bob_email = "bob@gomegam.com"
9
+ =begin
10
+ def test_signin_auth
11
+ response =megams.get_accounts("test@megam.io")
12
+ response.body.to_s
13
+ assert_equal(200, response.status)
14
+ end
15
+
16
+ =end
17
+ =begin
18
+ def test_get_accounts_good
19
+ response =megams.get_accounts("coolvader123@iamswag.com")
20
+ response.body.to_s
21
+ assert_equal(200, response.status)
22
+ end
23
+ =end
24
+ #=begin
25
+ def test_post_accounts_good
26
+ #=begin
27
+ tmp_hash = {
28
+ "id" => "000099090909000",
29
+ "email" => "coolvader123reee@iamswag.com",
30
+ "api_key" => "faketest",
31
+ "first_name" => "Darth",
32
+ "last_name" => "Vader",
33
+ "phone" => "1908877643",
34
+ "phone_verified" => "verified",
35
+ "password" => "user",
36
+ "password_reset_key" => "",
37
+ "password_reset_sent_at" => "",
38
+ "authority" => "admin",
39
+ "active" => "active",
40
+ "blocked" => "blocked",
41
+ "staged" => "",
42
+ "approved" => "approved",
43
+ "approved_by_id" => "",
44
+ "approved_at" => "",
45
+ "suspended" => "suspended",
46
+ "suspended_at" => "",
47
+ "suspended_till" => "",
48
+ "registration_ip_address" => "",
49
+ "last_posted_at" => "",
50
+ "last_emailed_at" => "",
51
+ "previous_visit_at" => "",
52
+ "first_seen_at" => "",
53
+ "created_at" => "2014-10-29 13:24:06 +0000"
54
+ }
55
+ #response =megams.post_accounts(tmp_hash)
56
+ response = Megam::Account.create(tmp_hash)
57
+ response.body.to_s
58
+ assert_equal(201, response.status)
59
+ end
60
+ #=end
61
+
62
+ =begin
63
+ def test_update_accounts_good
64
+ tmp_hash = {
65
+ "id" => "000099090909000",
66
+ "email" => "coolvader123reee@iamswag.com",
67
+ "api_key" => "faketest",
68
+ "first_name" => "Darth",
69
+ "last_name" => "Vader",
70
+ "phone" => "1908877643",
71
+ "phone_verified" => "verified",
72
+ "password" => "user",
73
+ "password_reset_key" => "",
74
+ "password_reset_sent_at" => "",
75
+ "authority" => "admin",
76
+ "active" => "active",
77
+ "blocked" => "blocked",
78
+ "staged" => "",
79
+ "approved" => "approved",
80
+ "approved_by_id" => "",
81
+ "approved_at" => "",
82
+ "suspended" => "suspended",
83
+ "suspended_at" => "",
84
+ "suspended_till" => "",
85
+ "registration_ip_address" => "",
86
+ "last_posted_at" => "",
87
+ "last_emailed_at" => "",
88
+ "previous_visit_at" => "",
89
+ "first_seen_at" => "",
90
+ "created_at" => "2014-10-29 13:24:06 +0000"
91
+ }
92
+ response = megams.update_accounts(tmp_hash)
93
+ response.body.to_s
94
+ assert_equal(201, response.status)
95
+ end
96
+ =end
97
+ =begin
98
+ def test_get_accounts_bad
99
+ assert_raises(Megam::API::Errors::NotFound) do
100
+ response =megams.get_accounts(sandbox_email+"_bad")
101
+ response.body.to_s
102
+ end
103
+ end
104
+ def test_post_accounts_admin
105
+ response =megams.post_accounts(
106
+ {:id => random_id, :email => $tom_email, :api_key => sandbox_apikey, :authority => $admin})
107
+ response.body.to_s
108
+ assert_equal(201, response.status)
109
+ end
110
+
111
+ def test_post_accounts_normal
112
+ response =megams.post_accounts(
113
+ {:id => random_id, :email => $bob_email, :api_key => sandbox_apikey, :authority => $normal})
114
+ response.body.to_s
115
+ assert_equal(201, response.status)
116
+ end
117
+
118
+ def test_post_accounts_normal_bad
119
+ assert_raises(ArgumentError) do
120
+ response =megam.post_accounts(
121
+ {:id => random_id, :emailo => sandbox_email,
122
+ :apik_key => sandbox_apikey, :authority => $admin})
123
+ response.body.to_s
124
+ end
125
+ end
126
+ =end
127
+ end