app42 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +119 -0
  6. data/Rakefile +5 -0
  7. data/TODO.txt +36 -0
  8. data/app42.gemspec +41 -0
  9. data/bin/app42 +15 -0
  10. data/lib/app42.rb +23 -0
  11. data/lib/app42/base/constants.rb +33 -0
  12. data/lib/app42/base/help.rb +717 -0
  13. data/lib/app42/base/http_helper.rb +46 -0
  14. data/lib/app42/base/message.rb +35 -0
  15. data/lib/app42/base/shell.rb +39 -0
  16. data/lib/app42/base/util.rb +304 -0
  17. data/lib/app42/client/app42_rest_client.rb +451 -0
  18. data/lib/app42/client/rest_util.rb +66 -0
  19. data/lib/app42/command/app.rb +194 -0
  20. data/lib/app42/command/authorize.rb +29 -0
  21. data/lib/app42/command/base.rb +660 -0
  22. data/lib/app42/command/client.rb +232 -0
  23. data/lib/app42/command/config.rb +185 -0
  24. data/lib/app42/command/info.rb +101 -0
  25. data/lib/app42/command/service.rb +196 -0
  26. data/lib/app42/command/user.rb +140 -0
  27. data/lib/app42/command/user_key.rb +68 -0
  28. data/lib/app42/version.rb +13 -0
  29. data/spec/app42/base/constants_spec.rb +11 -0
  30. data/spec/app42/command/app_spec.rb +103 -0
  31. data/spec/app42/command/base_spec.rb +7 -0
  32. data/spec/app42/command/config_spec.rb +20 -0
  33. data/spec/app42/command/info_spec.rb +27 -0
  34. data/spec/app42/command/service_spec.rb +98 -0
  35. data/spec/app42/command/user_spec.rb +7 -0
  36. data/spec/app42/command/user_token_spec.rb +40 -0
  37. data/spec/app42/version_spec.rb +7 -0
  38. data/spec/app42_spec.rb +2 -0
  39. data/spec/data/info.yml +16 -0
  40. data/spec/data/services.yml +25 -0
  41. data/spec/data/state.yml +16 -0
  42. data/spec/data/user_services.yml +18 -0
  43. data/spec/spec_helper.rb +18 -0
  44. metadata +257 -0
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'App42::Command' do
4
+ describe 'Base' do
5
+
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ # require 'spec_helper'
2
+
3
+ # # puts APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
4
+ # # puts $: << File.join(APP_ROOT, 'lib/app42') # so rspec knows where your file could be
5
+ # # require 'app42/command/config'
6
+
7
+ # describe 'App42::Command' do
8
+ # describe 'Config' do
9
+
10
+ # # before(:all) do
11
+ # # @config = App42::Command::Config.new
12
+ # # end
13
+
14
+ # it 'should list all runtime' do
15
+ # puts App42::Command::Config.new
16
+ # # runtime = config.get_config 'config', 'runtime'
17
+ # # puts runtime
18
+ # end
19
+ # end
20
+ # end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'App42::Command' do
4
+ describe 'Info' do
5
+
6
+ before(:all) do
7
+ @app_name = 'demo'
8
+ end
9
+
10
+ context("with right app name") do
11
+
12
+ it 'Should return correct app information json' do
13
+ respone = App42::Command::Base.new.app_information 'info', @app_name
14
+ path = "#{APP_ROOT}/app42/spec/data/info.yml"
15
+ info = YAML.load_file(path)
16
+ respone.should eql info
17
+ end
18
+
19
+ it 'Should return correct app state json' do
20
+ respone = App42::Command::Base.new.app_information 'state', @app_name
21
+ path = "#{APP_ROOT}/app42/spec/data/state.yml"
22
+ info = YAML.load_file(path)
23
+ respone.should eql info
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'App42::Command' do
4
+ describe "App" do
5
+
6
+ before(:all) do
7
+ @service = 1
8
+ @service_name = 'mysql_demo3'
9
+ @new_service_name = 'mysql_demo1'
10
+ @existing_service_name = 'mysql_demo'
11
+ @service_name_sc = 'mysql_demo@'
12
+ @old_password = 'wigqled83sh10lvf6ccrdsej78aeq37u'
13
+ @source_ip = '0.0.0.0/0'
14
+ @access_time = '2'
15
+ @iaas = 1
16
+ @vm_type = 'Shared'
17
+ @database = 'demo_development'
18
+ @os = 1
19
+ @vm_config = 1
20
+ end
21
+
22
+ context "With valid input data" do
23
+
24
+ it 'Should return service name available' do
25
+ response = App42::Command::Base.new.service_name_availability @service_name_sc
26
+ response.should eql @service_name
27
+ end
28
+
29
+ it 'Should create service' do
30
+ response = App42::Command::Base.new.create_service @service, @service_name ,@database, @vm_type, @iaas, @vmconfig, @os
31
+ response.should eql true
32
+ end
33
+
34
+ it 'should list all services' do
35
+ response = App42::Command::Service.new.services
36
+ end
37
+
38
+ it 'Should return correct service information json' do
39
+ respone = App42::Command::Service.new.info
40
+ end
41
+
42
+ it 'Should reset service password' do
43
+ response = App42::Command::Base.new.reset_password @service_name, @old_password
44
+ response['success'].should eql true
45
+ end
46
+
47
+ it 'Should bind service with source IP' do
48
+ response = App42::Command::Base.new.create_service_tunnel @service_name, @source_ip, @access_time
49
+ end
50
+
51
+ it 'Should Unbind service with source IP' do
52
+ response = App42::Command::Base.new.delete_service_tunnel @service_name, @source_ip
53
+ response.should eql true
54
+ end
55
+
56
+ it 'Should delete service' do
57
+ response = App42::Command::Base.new.delete_service @service_name
58
+ response.should eql true
59
+ end
60
+
61
+ end
62
+
63
+ context "Check service name availability with existing service name" do
64
+ it 'Should return rest exception: Service with name is not available.' do
65
+ response = App42::Command::Base.new.service_name_availability @existing_service_name
66
+ end
67
+ end
68
+
69
+ context "Create service with existing service name" do
70
+ it 'Should return rest exception: Service with name is not available.' do
71
+ response = App42::Command::Base.new.create_service @service, @service_name ,@database, @vm_type, @iaas, @vmconfig, @os
72
+ response.should eql true
73
+ end
74
+ end
75
+
76
+ context "Create service, name contain special charrecter" do
77
+ it "Service name should not contain any special character and it's length should be less than 30." do
78
+ response = App42::Command::Base.new.create_service @service, @service_name_sc ,@database, @vm_type, @iaas, @vmconfig, @os
79
+ end
80
+ end
81
+
82
+ # Unit testing
83
+ it "Should return app42PaaS services josn" do
84
+ response = App42::Command::Service.new.get_services
85
+ path = "#{APP_ROOT}/app42/spec/data/services.yml"
86
+ services = YAML.load_file(path)
87
+ response.should eql services
88
+ end
89
+
90
+ it "Should return user services josn" do
91
+ response = App42::Command::Service.new.get_user_services
92
+ path = "#{APP_ROOT}/app42/spec/data/user_services.yml"
93
+ service = YAML.load_file(path)
94
+ response.should eql service
95
+ end
96
+
97
+ end
98
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'App42::Command' do
4
+ describe 'User' do
5
+
6
+ end
7
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'app42/base/constants'
3
+
4
+ describe 'App42::Command' do
5
+ describe 'UserToken' do
6
+
7
+ it 'should ensure config dir' do
8
+ FileUtils.mkdir_p(config_path).first.should eql "#{Dir.home}/.app42"
9
+ end
10
+
11
+ it 'should check key file presence?' do
12
+ info = YAML.load_file(key_path)
13
+ info['api_key'].should_not be_nil
14
+ info['secret_key'].should_not be_nil
15
+ end
16
+
17
+ it 'should return config path' do
18
+ config_path.should eql "#{Dir.home}/.app42"
19
+ end
20
+
21
+ it 'should return key_file' do
22
+ key_path.should eql "#{Dir.home}/.app42/app42paas.yml"
23
+ expect(key_path).to end_with(".yml")
24
+ end
25
+
26
+ # it 'should remove key file' do
27
+ # FileUtils.rm_f(key_path)
28
+ # expect { YAML.load_file(key_path) }.to raise_error(Errno::ENOENT)
29
+ # end
30
+
31
+ def config_path
32
+ File.expand_path(App42::CONFIG_DIR)
33
+ end
34
+
35
+ def key_path
36
+ File.expand_path(App42::KEYS_FILE)
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe App42::Version do
4
+ it 'should return correct version string' do
5
+ App42::Version::VERSION::VERSION.should == "0.5.0"
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require 'spec_helper'
2
+
@@ -0,0 +1,16 @@
1
+ {
2
+ "success": true,
3
+ "appInfo": {
4
+ "appUrl": "demo.aws.app42paas.com",
5
+ "appStatus": "RUNNING",
6
+ "os": "Ubuntu 12.10",
7
+ "containerCount": 1,
8
+ "iaasProvider": "Amazon",
9
+ "vmType": "Shared",
10
+ "name": "demo",
11
+ "runtime": "Ruby 2.0",
12
+ "webServer": "nginx 1.4.0",
13
+ "framework": "Rails 4.0",
14
+ "memory": "512 MB"
15
+ }
16
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "success": true,
3
+ "services": [
4
+ {
5
+ "id": 1,
6
+ "name": "MySQL",
7
+ "version": "5.5.1"
8
+ },
9
+ {
10
+ "id": 2,
11
+ "name": "Mongodb",
12
+ "version": "2.4"
13
+ },
14
+ {
15
+ "id": 3,
16
+ "name": "Couchdb",
17
+ "version": "10.1"
18
+ },
19
+ {
20
+ "id": 4,
21
+ "name": "PostgreSQL",
22
+ "version": "9.1"
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "success": true,
3
+ "appInfo": {
4
+ "appUrl": "demo.aws.app42paas.com",
5
+ "appStatus": "RUNNING",
6
+ "os": "Ubuntu 12.10",
7
+ "containerCount": 1,
8
+ "iaasProvider": "Amazon",
9
+ "vmType": "Shared",
10
+ "name": "demo",
11
+ "runtime": "Ruby 2.0",
12
+ "webServer": "nginx 1.4.0",
13
+ "framework": "Rails 4.0",
14
+ "memory": "512 MB"
15
+ }
16
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "success": true,
3
+ "services": [
4
+ {
5
+ "databaseName": "demo_db1",
6
+ "os": "Ubuntu 12.10",
7
+ "iaasProvider": "Amazon",
8
+ "vmType": "Shared",
9
+ "name": "mysql_demo3",
10
+ "vmIp": "10.0.0.52",
11
+ "userName": "hzy278x7ord24lqz",
12
+ "vmPort": "31219",
13
+ "serviceType": "MySQL 5.5.1",
14
+ "password": "z6jl15dseiv8njfefp3ecuneix27y05w",
15
+ "memory": "512 MB"
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,18 @@
1
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
2
+ $: << File.join(APP_ROOT, 'lib/app42') # so rspec knows where your file could be
3
+
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+ require 'rspec'
7
+ require 'yaml'
8
+ require 'app42'
9
+
10
+ command_dir = "#{APP_ROOT}/app42/lib/app42/{command}/*.rb"
11
+ Dir[File.expand_path(command_dir, __FILE__)].each do |file|
12
+ require file
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.color_enabled = true
17
+ config.formatter = 'documentation'
18
+ end
metadata ADDED
@@ -0,0 +1,257 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: app42
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.3
5
+ platform: ruby
6
+ authors:
7
+ - ShepHertz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.18
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.18
55
+ - !ruby/object:Gem::Dependency
56
+ name: paint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.6
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.6.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.6.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: json_pure
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.6
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.6
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-hmac
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.4.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.4.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: interact
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.5.2
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 0.5.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: terminal-table
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 1.4.2
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 1.4.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: ipaddress
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: '2.5'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: '2.5'
167
+ description: Client library and command-line tool to deploy and manage apps on App42PaaS.
168
+ email:
169
+ - support@shephertz.com
170
+ executables:
171
+ - app42
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - .gitignore
176
+ - Gemfile
177
+ - LICENSE.txt
178
+ - README.md
179
+ - Rakefile
180
+ - TODO.txt
181
+ - app42.gemspec
182
+ - bin/app42
183
+ - lib/app42.rb
184
+ - lib/app42/base/constants.rb
185
+ - lib/app42/base/help.rb
186
+ - lib/app42/base/http_helper.rb
187
+ - lib/app42/base/message.rb
188
+ - lib/app42/base/shell.rb
189
+ - lib/app42/base/util.rb
190
+ - lib/app42/client/app42_rest_client.rb
191
+ - lib/app42/client/rest_util.rb
192
+ - lib/app42/command/app.rb
193
+ - lib/app42/command/authorize.rb
194
+ - lib/app42/command/base.rb
195
+ - lib/app42/command/client.rb
196
+ - lib/app42/command/config.rb
197
+ - lib/app42/command/info.rb
198
+ - lib/app42/command/service.rb
199
+ - lib/app42/command/user.rb
200
+ - lib/app42/command/user_key.rb
201
+ - lib/app42/version.rb
202
+ - spec/app42/base/constants_spec.rb
203
+ - spec/app42/command/app_spec.rb
204
+ - spec/app42/command/base_spec.rb
205
+ - spec/app42/command/config_spec.rb
206
+ - spec/app42/command/info_spec.rb
207
+ - spec/app42/command/service_spec.rb
208
+ - spec/app42/command/user_spec.rb
209
+ - spec/app42/command/user_token_spec.rb
210
+ - spec/app42/version_spec.rb
211
+ - spec/app42_spec.rb
212
+ - spec/data/info.yml
213
+ - spec/data/services.yml
214
+ - spec/data/state.yml
215
+ - spec/data/user_services.yml
216
+ - spec/spec_helper.rb
217
+ homepage: http://shephertz.com
218
+ licenses:
219
+ - MIT
220
+ metadata: {}
221
+ post_install_message: Thanks for installing!
222
+ rdoc_options: []
223
+ require_paths:
224
+ - lib
225
+ required_ruby_version: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '>='
228
+ - !ruby/object:Gem::Version
229
+ version: 1.9.2
230
+ required_rubygems_version: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - '>='
233
+ - !ruby/object:Gem::Version
234
+ version: '0'
235
+ requirements: []
236
+ rubyforge_project:
237
+ rubygems_version: 2.0.3
238
+ signing_key:
239
+ specification_version: 4
240
+ summary: Client library and command-line tool to deploy and manage apps on App42PaaS
241
+ Server.
242
+ test_files:
243
+ - spec/app42/base/constants_spec.rb
244
+ - spec/app42/command/app_spec.rb
245
+ - spec/app42/command/base_spec.rb
246
+ - spec/app42/command/config_spec.rb
247
+ - spec/app42/command/info_spec.rb
248
+ - spec/app42/command/service_spec.rb
249
+ - spec/app42/command/user_spec.rb
250
+ - spec/app42/command/user_token_spec.rb
251
+ - spec/app42/version_spec.rb
252
+ - spec/app42_spec.rb
253
+ - spec/data/info.yml
254
+ - spec/data/services.yml
255
+ - spec/data/state.yml
256
+ - spec/data/user_services.yml
257
+ - spec/spec_helper.rb