virtengine_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +11 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +27 -0
- data/Rakefile +10 -0
- data/lib/megam/api.rb +329 -0
- data/lib/megam/api/accounts.rb +96 -0
- data/lib/megam/api/addons.rb +27 -0
- data/lib/megam/api/assemblies.rb +49 -0
- data/lib/megam/api/assembly.rb +56 -0
- data/lib/megam/api/backups.rb +57 -0
- data/lib/megam/api/balances.rb +45 -0
- data/lib/megam/api/billedhistories.rb +35 -0
- data/lib/megam/api/billingtransactions.rb +25 -0
- data/lib/megam/api/components.rb +24 -0
- data/lib/megam/api/credits.rb +34 -0
- data/lib/megam/api/disks.rb +44 -0
- data/lib/megam/api/domains.rb +25 -0
- data/lib/megam/api/errors.rb +29 -0
- data/lib/megam/api/eventsall.rb +36 -0
- data/lib/megam/api/eventsbilling.rb +35 -0
- data/lib/megam/api/eventscontainer.rb +35 -0
- data/lib/megam/api/eventsmarketplace.rb +35 -0
- data/lib/megam/api/eventsstorage.rb +24 -0
- data/lib/megam/api/eventsvm.rb +35 -0
- data/lib/megam/api/flavors.rb +56 -0
- data/lib/megam/api/license.rb +26 -0
- data/lib/megam/api/marketplaces.rb +68 -0
- data/lib/megam/api/organizations.rb +50 -0
- data/lib/megam/api/promos.rb +18 -0
- data/lib/megam/api/quotas.rb +47 -0
- data/lib/megam/api/rawimages.rb +36 -0
- data/lib/megam/api/reports.rb +24 -0
- data/lib/megam/api/requests.rb +36 -0
- data/lib/megam/api/sensors.rb +35 -0
- data/lib/megam/api/snapshots.rb +46 -0
- data/lib/megam/api/sshkeys.rb +35 -0
- data/lib/megam/api/subscriptions.rb +26 -0
- data/lib/megam/api/version.rb +6 -0
- data/lib/megam/core/account.rb +245 -0
- data/lib/megam/core/account_collection.rb +122 -0
- data/lib/megam/core/addons.rb +169 -0
- data/lib/megam/core/addons_collection.rb +121 -0
- data/lib/megam/core/assemblies.rb +191 -0
- data/lib/megam/core/assemblies_collection.rb +122 -0
- data/lib/megam/core/assembly.rb +226 -0
- data/lib/megam/core/assembly_collection.rb +122 -0
- data/lib/megam/core/backups.rb +259 -0
- data/lib/megam/core/backups_collection.rb +122 -0
- data/lib/megam/core/balances.rb +187 -0
- data/lib/megam/core/balances_collection.rb +121 -0
- data/lib/megam/core/billedhistories.rb +190 -0
- data/lib/megam/core/billedhistories_collection.rb +121 -0
- data/lib/megam/core/billingtransactions.rb +214 -0
- data/lib/megam/core/billingtransactions_collection.rb +122 -0
- data/lib/megam/core/components.rb +326 -0
- data/lib/megam/core/components_collection.rb +123 -0
- data/lib/megam/core/credits.rb +146 -0
- data/lib/megam/core/credits_collection.rb +121 -0
- data/lib/megam/core/disks.rb +199 -0
- data/lib/megam/core/disks_collection.rb +122 -0
- data/lib/megam/core/domain_collection.rb +122 -0
- data/lib/megam/core/domains.rb +118 -0
- data/lib/megam/core/error.rb +70 -0
- data/lib/megam/core/eventsall.rb +186 -0
- data/lib/megam/core/eventsall_collection.rb +122 -0
- data/lib/megam/core/eventsbilling.rb +174 -0
- data/lib/megam/core/eventsbilling_collection.rb +122 -0
- data/lib/megam/core/eventscontainer.rb +187 -0
- data/lib/megam/core/eventscontainer_collection.rb +122 -0
- data/lib/megam/core/eventsmarketplace.rb +187 -0
- data/lib/megam/core/eventsmarketplace_collection.rb +122 -0
- data/lib/megam/core/eventsstorage.rb +156 -0
- data/lib/megam/core/eventsstorage_collection.rb +122 -0
- data/lib/megam/core/eventsvm.rb +187 -0
- data/lib/megam/core/eventsvm_collection.rb +122 -0
- data/lib/megam/core/flavors.rb +294 -0
- data/lib/megam/core/flavors_collection.rb +121 -0
- data/lib/megam/core/json_compat.rb +289 -0
- data/lib/megam/core/konipai.rb +42 -0
- data/lib/megam/core/license.rb +101 -0
- data/lib/megam/core/license_collection.rb +122 -0
- data/lib/megam/core/log.rb +19 -0
- data/lib/megam/core/marketplace.rb +308 -0
- data/lib/megam/core/marketplace_collection.rb +123 -0
- data/lib/megam/core/monologger.rb +89 -0
- data/lib/megam/core/organizations.rb +142 -0
- data/lib/megam/core/organizations_collection.rb +121 -0
- data/lib/megam/core/promos.rb +145 -0
- data/lib/megam/core/quotas.rb +215 -0
- data/lib/megam/core/quotas_collection.rb +121 -0
- data/lib/megam/core/rawimages.rb +194 -0
- data/lib/megam/core/rawimages_collection.rb +121 -0
- data/lib/megam/core/reports.rb +176 -0
- data/lib/megam/core/reports_collection.rb +121 -0
- data/lib/megam/core/request.rb +197 -0
- data/lib/megam/core/request_collection.rb +121 -0
- data/lib/megam/core/rest_adapter.rb +44 -0
- data/lib/megam/core/sensors.rb +141 -0
- data/lib/megam/core/sensors_collection.rb +121 -0
- data/lib/megam/core/snapshots.rb +268 -0
- data/lib/megam/core/snapshots_collection.rb +122 -0
- data/lib/megam/core/sshkey.rb +173 -0
- data/lib/megam/core/sshkey_collection.rb +122 -0
- data/lib/megam/core/stuff.rb +22 -0
- data/lib/megam/core/subscriptions.rb +167 -0
- data/lib/megam/core/subscriptions_collection.rb +121 -0
- data/lib/megam/core/text.rb +87 -0
- data/lib/megam/core/text_formatter.rb +64 -0
- data/lib/megam/mixins/assemblies.rb +16 -0
- data/lib/megam/mixins/assembly.rb +59 -0
- data/lib/megam/mixins/common_deployable.rb +78 -0
- data/lib/megam/mixins/components.rb +182 -0
- data/lib/megam/mixins/megam_attributes.rb +30 -0
- data/lib/megam/mixins/outputs.rb +23 -0
- data/lib/megam/mixins/policies.rb +27 -0
- data/lib/megam_api.rb +1 -0
- data/megam_api.gemspec +26 -0
- data/test/mixins/test_assemblies.rb +113 -0
- data/test/mixins/test_assembly.rb +74 -0
- data/test/mixins/test_component.rb +19 -0
- data/test/test_accounts.rb +127 -0
- data/test/test_addons.rb +26 -0
- data/test/test_assemblies.rb +88 -0
- data/test/test_assembly.rb +37 -0
- data/test/test_backups.rb +29 -0
- data/test/test_balances.rb +38 -0
- data/test/test_billedhistories.rb +30 -0
- data/test/test_billingtranscations.rb +35 -0
- data/test/test_components.rb +42 -0
- data/test/test_credits.rb +28 -0
- data/test/test_disks.rb +25 -0
- data/test/test_domains.rb +29 -0
- data/test/test_eventsbilling.rb +30 -0
- data/test/test_eventscontainer.rb +26 -0
- data/test/test_eventsstorage.rb +12 -0
- data/test/test_eventsvm.rb +26 -0
- data/test/test_helper.rb +77 -0
- data/test/test_marketplaces.rb +38 -0
- data/test/test_organizations.rb +45 -0
- data/test/test_promos.rb +11 -0
- data/test/test_quotas.rb +33 -0
- data/test/test_reports.rb +32 -0
- data/test/test_requests.rb +95 -0
- data/test/test_sensors.rb +50 -0
- data/test/test_snapshots.rb +30 -0
- data/test/test_sshkeys.rb +50 -0
- data/test/test_subscriptions.rb +22 -0
- 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
|