megam_api 0.92 → 0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,35 +2,32 @@ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestAccounts < MiniTest::Unit::TestCase
4
4
 
5
- $admin = "admin-tom"
6
- $normal = "normal-tom"
7
- $tom_email = "tom@gomegam.com"
8
- $bob_email = "bob@gomegam.com"
5
+
9
6
  =begin
10
- def test_get_accounts_good
11
- response =megams.get_accounts(sandbox_email)
7
+ def test_signin_auth
8
+ response = megams.get_accounts("test@megam.io")
12
9
  response.body.to_s
13
10
  assert_equal(200, response.status)
14
- end
11
+ end
15
12
  =end
13
+ #=begin
16
14
  def test_post_accounts_good
17
15
  tmp_hash = {
18
- "id" => "000099090909000",
19
16
  "first_name" => "Darth",
20
17
  "last_name" => "Vader",
21
- "email" => "coolvader@iamswag.com",
18
+ "email" => "test@megam.io",
22
19
  "phone" => "19090909090",
23
20
  "api_key" => "IamAtlas{74}NobdyCanSedfefdeME#07",
24
21
  "authority" => "admin",
25
- "password" => "",
22
+ "password" => Base64.strict_encode64("megam"),
26
23
  "password_reset_key" => "",
27
24
  "password_reset_sent_at" => "",
28
- "created_at" => "2014-10-29 13:24:06 +0000"
29
25
  }
30
- response =megams.post_accounts(tmp_hash)
26
+ response =megams_new.post_accounts(tmp_hash)
31
27
  response.body.to_s
32
28
  assert_equal(201, response.status)
33
29
  end
30
+ #=end
34
31
 
35
32
  =begin
36
33
  def test_update_accounts_good
@@ -58,28 +55,5 @@ class TestAccounts < MiniTest::Unit::TestCase
58
55
  response.body.to_s
59
56
  end
60
57
  end
61
-
62
- def test_post_accounts_admin
63
- response =megams.post_accounts(
64
- {:id => random_id, :email => $tom_email, :api_key => sandbox_apikey, :authority => $admin})
65
- response.body.to_s
66
- assert_equal(201, response.status)
67
- end
68
-
69
- def test_post_accounts_normal
70
- response =megams.post_accounts(
71
- {:id => random_id, :email => $bob_email, :api_key => sandbox_apikey, :authority => $normal})
72
- response.body.to_s
73
- assert_equal(201, response.status)
74
- end
75
-
76
- def test_post_accounts_normal_bad
77
- assert_raises(ArgumentError) do
78
- response =megam.post_accounts(
79
- {:id => random_id, :emailo => sandbox_email,
80
- :apik_key => sandbox_apikey, :authority => $admin})
81
- response.body.to_s
82
- end
83
- end
84
- =end
58
+ =end
85
59
  end
@@ -8,88 +8,84 @@ class TestApps < MiniTest::Unit::TestCase
8
8
  assert_equal(200, response.status)
9
9
  end
10
10
  =end
11
- =begin
11
+ #=begin
12
12
  def test_get_assembly
13
- response = megams.get_one_assemblies("AMS1257720849197301760")
13
+ response = megams.get_one_assemblies("AMS4910703635659237712")
14
14
  assert_equal(200, response.status)
15
15
  end
16
- =end
16
+ #=end
17
17
 
18
- #=begin
18
+ =begin
19
19
  def test_post_assembly
20
20
  tmp_hash = {
21
- "name" => "testAsm",
22
- "org_id" => "ORG123",
23
- "assemblies" => [{
24
- "name" => "PaulineHarper",
25
- "components" => [{
26
- "name" => "GussieMathis",
27
- "tosca_type" => "tosca.web.riak",
28
- "inputs" => [],
29
- "status" => "",
30
- "related_components" => ["VernonDennis.megam.co"],
31
- "outputs" => [],
32
- "envs" => [{
33
- "key" => "REDIS_HOST",
34
- "value" => "tempp.megambox.com"
35
- }],
36
- "artifacts" => {
37
- "artifact_type" => "tosca_type",
38
- "content" => "",
39
- "artifact_requirements" => []
40
- },
41
- "operations" => [{
42
- "operation_type" => "CI",
43
- "description" => "continuous Integration",
44
- "properties" => []
45
- }],
46
- "repo" => {
47
- "rtype" => "image",
48
- "source" => "github",
49
- "oneclick" => "yes",
50
- "url" => "imagename"
51
- }
52
- }],
53
- "tosca_type" => "tosca.torpedo.coreos",
54
- "inputs" => [{
55
- "key" => "Domain",
56
- "value" => ""
57
- },
58
- {
59
- "key" => "sshKey",
60
- "value" => "rsa"
61
- }
62
-
63
- ],
64
- "outputs" => [],
65
- "status" => "",
66
- "policies" => [
67
- {
68
- "name" => "placement policy",
69
- "ptype" => "colocated",
70
- "members" => ["apache2-megam"]
71
- },
72
- {
73
- "name" => "HA policy",
74
- "ptype" => "colocated",
75
- "members" => ["apache2-megam"]
76
- },
77
- {
78
- "name" => "CPU scaling for apache2 server",
79
- "ptype" => "scaling",
80
- "members" => ["apache2-megam"],
81
- "rules" => {
82
- "name" => "cpu load",
83
- "type" => "cpu",
84
- "cpu_threshhold" => "80"
85
- }
86
- }
87
- ]
88
- } ],
89
- "inputs" => []
90
- }
21
+ "name"=>"",
22
+ "org_id"=>"ORG123",
23
+ "assemblies"=>[{
24
+ "name"=>"covey",
25
+ "tosca_type"=>"tosca.app.java",
26
+ "inputs"=>[
27
+ {"key"=>"domain","value"=>"megambox.com"},
28
+ {"key"=>"sshkey","value"=>"a@b.com_rtr"},
29
+ {"key"=>"provider","value"=>"one"},
30
+ {"key"=>"cpu","value"=>"0.5"},
31
+ {"key"=>"ram","value"=>"896"},
32
+ {"key"=>"version","value"=>"8.x"},
33
+ {"key"=>"lastsuccessstatusupdate","value"=>"02 Feb 16 13:20 IST"},
34
+ {"key"=>"status","value"=>"error"}
35
+ ],
36
+ "outputs"=>[],
37
+ "policies"=>[],
38
+ "status"=>"error",
39
+ "created_at"=>"2016-02-02 07:50:49 +0000",
40
+ "components"=>[
41
+ {
42
+ "name"=>"sheba",
43
+ "tosca_type"=>"tosca.app.java",
44
+ "inputs"=>[
45
+ {"key"=>"domain","value"=>"megambox.com"},
46
+ {"key"=>"sshkey","value"=>"a@b.com_rtr"},
47
+ {"key"=>"provider","value"=>"one"},
48
+ {"key"=>"cpu","value"=>"0.5"},
49
+ {"key"=>"ram","value"=>"896"},
50
+ {"key"=>"version","value"=>"8.x"},
51
+ {"key"=>"lastsuccessstatusupdate","value"=>"02 Feb 16 13:20 IST"},
52
+ {"key"=>"status","value"=>"error"}
53
+ ],
54
+ "outputs"=>[],
55
+ "envs"=>[
56
+ {"key"=>"port","value"=>"8080"},
57
+ {"key"=>"tomcat_username","value"=>"megam"},
58
+ {"key"=>"tomcat_password","value"=>"megam"}
59
+ ],
60
+ "repo"=>{
61
+ "rtype"=>"source",
62
+ "source"=>"github",
63
+ "oneclick"=>"","url"=>"https://github.com/rajthilakmca/java-spring-petclinic.git"
64
+ },
65
+ "artifacts"=>{"artifact_type"=>"","content"=>"","requirements"=>[]},
66
+ "related_components"=>[],
67
+ "operations"=>[{
68
+ "operation_type"=>"CI",
69
+ "description"=>"always up to date code. sweet.",
70
+ "properties"=>[
71
+ {"key"=>"type","value"=>"github"},
72
+ {"key"=>"token","value"=>"066b697558f048459412410483ca8965415bf7de"},
73
+ {"key"=>"username","value"=>"rajthilakmca"}],
74
+ "status"=>"notbound"}],
75
+ "status"=>"error"}]}],
76
+ "inputs"=>[
77
+ {"key"=>"domain","value"=>"megambox.com"},
78
+ {"key"=>"sshkey","value"=>"a@b.com_rtr"},
79
+ {"key"=>"provider","value"=>"one"},
80
+ {"key"=>"cpu","value"=>"0.5"},
81
+ {"key"=>"ram","value"=>"896"},
82
+ {"key"=>"version","value"=>"8.x"},
83
+ {"key"=>"lastsuccessstatusupdate","value"=>"02 Feb 16 13:20 IST"},
84
+ {"key"=>"status","value"=>"error"}]
85
+ }
86
+
91
87
  response = megams.post_assemblies(tmp_hash)
92
88
  assert_equal(200, response.status)
93
89
  end
94
- #=end
90
+ =end
95
91
  end
@@ -1,41 +1,22 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- #=begin
5
- def test_post_assembly
6
- tmp_hash = { "name" => "calcines",
7
- "components" => ["COM1270769168056188928",""],
8
- "tosca_type" => "",
9
- "policies" => [{
10
- "name" => "bind policy",
11
- "ptype" => "colocated",
12
- "members" => ["calcines.megam.co/MattieGarcia","calcines.megam.co/parsnip"]
13
- }],
14
- "inputs" => [],
15
- "output" => [],
16
- "status" => "Launching",
17
- "created_at" => "2015-10-12 13:24:06 +0000"
18
-
19
- }
20
4
 
21
- response = megams.post_assembly(tmp_hash)
22
- assert_equal(201, response.status)
23
- end
24
- #=end
25
5
  =begin
26
6
  def test_get_assembly
27
- response = megams.get_one_assembly("ASY1273588307275677696")
7
+ response = megams.get_one_assembly("ASM9070050271024385313")
28
8
  assert_equal(200, response.status)
29
9
  end
30
10
  =end
31
- =begin
11
+ #=begin
32
12
  def test_update_assembly
33
13
  tmp_hash = {
34
14
 
35
- "id" => "ASM1265630517177483264",
15
+ "id" => "ASM9070050271024385313",
16
+ "org_id" => "ORG123",
36
17
  "json_claz" => "Megam::Assembly",
37
18
  "name" => "calcines",
38
- "tosca_type" => "",
19
+ "tosca_type" => "tosca.app.java",
39
20
  "components" => ["COM1265630517194260480",""],
40
21
  "policies" => [{
41
22
  "name" => "bind policy",
@@ -50,5 +31,5 @@ class TestApps < MiniTest::Unit::TestCase
50
31
  response = megams.update_assembly(tmp_hash)
51
32
  assert_equal(201, response.status)
52
33
  end
53
- =end
34
+ #=end
54
35
  end
@@ -1,16 +1,16 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- #=begin
4
+ =begin
5
5
  def test_get_component
6
- response = megams.get_components("COM1271871641852444672")
6
+ response = megams.get_components("COM7940692507005379013")
7
7
  assert_equal(200, response.status)
8
8
  end
9
- #=end
10
- =begin
9
+ =end
10
+ #=begin
11
11
  def test_update_component
12
12
  tmp_hash = {
13
- "id" => "COM1271850006541893632",
13
+ "id" => "COM7940692507005379013",
14
14
  "name" => "NettieMoore",
15
15
  "tosca_type" => "tosca.web.redis",
16
16
  "inputs" => [],
@@ -37,5 +37,5 @@ class TestApps < MiniTest::Unit::TestCase
37
37
  response = megams.update_component(tmp_hash)
38
38
  assert_equal(201, response.status)
39
39
  end
40
- =end
40
+ #=end
41
41
  end
data/test/test_helper.rb CHANGED
@@ -7,10 +7,9 @@ require 'time'
7
7
 
8
8
  SANDBOX_HOST_OPTIONS = {
9
9
  :scheme => 'http',
10
- :host => '127.0.0.1',
10
+ :host => 'localhost',
11
11
  :nonblock => false,
12
12
  :port => 9000
13
- #:port => 443
14
13
  }
15
14
 
16
15
 
@@ -21,20 +20,22 @@ end
21
20
 
22
21
  def megams_new(options={})
23
22
  s_options = SANDBOX_HOST_OPTIONS.merge({
24
- :email => "coolvader@iamswag.com",
23
+ :email => "test@megam.io",
25
24
  :api_key => "IamAtlas{74}NobdyCanSedfefdeME#07"
26
25
  })
27
26
  options = s_options.merge(options)
28
27
  mg=Megam::API.new(options)
29
28
  end
30
29
 
31
-
32
30
  def megams(options={})
33
31
  s_options = SANDBOX_HOST_OPTIONS.merge({
34
- :email => sandbox_email,
35
- :api_key => sandbox_apikey
36
-
32
+ :email => "test@megam.io",
33
+ :api_key => "IamAtlas{74}NobdyCanSedfefdeME#07",
34
+ :org_id => "ORG123",
35
+ #:password => "bWVnYW0="
37
36
  })
37
+
38
+
38
39
  Megam::Log.level(:debug)
39
40
  options = s_options.merge(options)
40
41
  mg=Megam::API.new(options)
@@ -73,7 +74,5 @@ def sandbox_apikey
73
74
  end
74
75
 
75
76
  def sandbox_email
76
- # "darth@vader.com"
77
- #"qwe@qwe.co"
78
- "coolvader@iamswag.com"
77
+ "tour@megam.io"
79
78
  end
@@ -1,6 +1,8 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestMarketplaces < MiniTest::Unit::TestCase
4
+
5
+
4
6
  =begin
5
7
  def test_post_marketplace
6
8
  tmp_hash = {
@@ -28,9 +30,9 @@ class TestMarketplaces < MiniTest::Unit::TestCase
28
30
  end
29
31
  #=end
30
32
  =begin
31
- def test_get_marketplace
32
- response = megams.get_marketplaceapp("Mysql")
33
- assert_equal(200, response.status)
34
- end
33
+ def test_show_marketplace_item
34
+ response = megams.get_marketplaceapp("Apache")
35
+ assert_equal(200, response.status)
36
+ end
35
37
  =end
36
38
  end
@@ -7,29 +7,22 @@ class TestOrganizations < MiniTest::Unit::TestCase
7
7
  $tom_email = "tom@gomegam.com"
8
8
  $bob_email = "bob@gomegam.com"
9
9
 
10
- =begin
11
- def test_get_organizations_good
12
- response =megams.get_organization(sandbox_name)
13
- response.body.to_s
14
- assert_equal(200, response.status)
15
- end
16
10
 
11
+ =begin
17
12
  def test_post_organizations_good
18
13
  tmp_hash = {
19
14
  "name" => "org.megam1"}
20
15
  response =megams.post_organization(tmp_hash)
21
- puts "printing--------------------->>>>"
22
- puts response.body.to_s
23
- puts "printingzzzzzzzzzzzzzzzzzzzzzzzz>>>>>"
24
- #response.body.to_s
25
- #assert_equal(201, response.status)
16
+ assert_equal(201, response.status)
26
17
  end
27
-
18
+ =end
19
+ #=begin
28
20
  def test_get_organizations_good1
29
21
  response =megams.get_organizations
30
22
  assert_equal(200, response.status)
31
23
  end
32
- =end
24
+ #=end
25
+ =begin
33
26
  def test_update_organizations
34
27
  tmp_hash = {
35
28
  "id" => "ORG123",
@@ -42,6 +35,7 @@ def test_update_organizations
42
35
  response.body.to_s
43
36
  assert_equal(201, response.status)
44
37
  end
38
+ =end
45
39
  =begin
46
40
  def test_get_organization
47
41
  response = megams.get_organization("ORG1257711897088753664")
data/test/test_sshkeys.rb CHANGED
@@ -1,24 +1,57 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
+
5
+ =begin
4
6
  def test_post_sshkey2
5
- tmp_hash = { :name => "test_sample", :path => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/megam@mypaas.io/default" }
7
+ tmp_hash = {
8
+ :name => "test_sample1",
9
+ :org_id => "ORG123",
10
+ :privatekey => "-----BEGIN RSA PRIVATE KEY-----
11
+ MIIEpQIBAAKCAQEAz9g/LhHB7fDo85vm2O9F1oDzJhTs6PI3N6WDayZEzG4xmrZd
12
+ lUgRoPAbYxYoiENeXwK9cy3D8lvqCVCog0E2oDXc7fe+LiLA+J+MYEkGfhs7hYfc
13
+ snLY36w52U0rVSVzwxak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L6qzsUYi0
29
+ C1qdz4Ki3M4BbcbRWzJcLIe96BkD4fEP1YYCPCQRbmh9o0gKVYr/1tmtqUE3dOPv
30
+ q48DuFaQoP4/dZx7EWgiivkCgYEAjpRSw7OXH3J9PJvZdeeqS3WFqZtRtVqwpQ8O
31
+ Jj9HjjevwccbSkZLSoidHWn4udo1+5xF6rHmABOTq/rOHcqdQdP93EBOHw5YNKYV
32
+ BSBpQj0q7iWZ46eXphE6IdQOY3U0ZVCA3uyKxLQVkacZ86at5zJnkx7I5C3zqI7c
33
+ 1u8niAECgYEAkXXNaH5iY5UmQIWCj50ksEi8TA9obYcKtRC4PL80iwvRUK3QDKv2
34
+ 7MYUIar1YtZWoZub0wsnPxYw8oiANR6hXQvTrfkM+3Hb+2wUrWycQ0FkJ5We+ldE
35
+ txyXl+iiF1+Nco4t/Jj3VvgzoIa25oQp2aeQhY7oot04UyyOYkPkkRQ=
36
+ -----END RSA PRIVATE KEY-----",
37
+ :publickey => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDP2D8uEcHt8Ojzm+bY70XWgPMmFOzo8jc3pYNrJkTMbjGatl2VSBGg8BtjFiiIQ15fAr1zLcPyW+oJUKiDQTagNdzt974uIsD4n4xgSQZ+GzuFh9yyctjfrDnZTStVJXPDFqRldtPnI9MVopg77jyGpGidWszbmU+N+Rz93XkyDi/z+JWr2nlNzWOdWDkIBOXM+1eTe10ReAdzLtvP0dIvmZxNEQqlQomMegCvWqLkD/AH2DXDjnCyEAK4yExxEhbNuphod/bTKmEY5D8PPenEfKCYkd6Y5y2t0wUCYfOVjtCATV90VFN4oqdrSslMnuxRN/oi7AW3RCyp4+c3ltOJ",
38
+ }
6
39
  response = megams.post_sshkey(tmp_hash)
7
40
  assert_equal(201, response.status)
8
41
  end
9
-
42
+ =end
10
43
  =begin
11
44
  def test_get_sshkeys
12
45
  response = megams.get_sshkeys
13
46
  assert_equal(200, response.status)
14
47
  end
15
48
  =end
16
- =begin
49
+ #=begin
17
50
  def test_get_sshkey2
18
- response = megams.get_sshkey("rkspce_sundown_play")
51
+ response = megams.get_sshkey("test_sample1")
19
52
  assert_equal(200, response.status)
20
53
  end
21
- =end
54
+ #=end
22
55
  =begin
23
56
  def test_get_sshkey1
24
57
  response = megams.get_sshkey("iaas_default")