dawn-api 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/dawn/api/authenticate.rb +33 -7
- data/lib/dawn/api/base_api.rb +52 -6
- data/lib/dawn/api/health_check.rb +14 -0
- data/lib/dawn/api/hosts.rb +16 -3
- data/lib/dawn/api/models/account.rb +44 -15
- data/lib/dawn/api/models/app/domains.rb +30 -6
- data/lib/dawn/api/models/app/drains.rb +30 -6
- data/lib/dawn/api/models/app/env.rb +19 -5
- data/lib/dawn/api/models/app/gears.rb +31 -7
- data/lib/dawn/api/models/app/releases.rb +28 -8
- data/lib/dawn/api/models/app.rb +93 -16
- data/lib/dawn/api/models/domain.rb +36 -11
- data/lib/dawn/api/models/drain.rb +33 -19
- data/lib/dawn/api/models/gear.rb +45 -25
- data/lib/dawn/api/models/key.rb +33 -15
- data/lib/dawn/api/models/login.rb +5 -4
- data/lib/dawn/api/models/release.rb +32 -14
- data/lib/dawn/api/safe/base_api.rb +3 -3
- data/lib/dawn/api/safe/safe_extension.rb +20 -5
- data/lib/dawn/api/version.rb +5 -5
- data/lib/dawn/api.rb +1 -1
- data/spec/api/account_spec.rb +21 -0
- data/spec/api/app/domains_spec.rb +30 -0
- data/spec/api/app/drains_spec.rb +30 -0
- data/spec/api/app/gears_spec.rb +38 -0
- data/spec/api/app/releases_spec.rb +30 -0
- data/spec/api/app_spec.rb +166 -0
- data/spec/api/domain_spec.rb +54 -0
- data/spec/api/drain_spec.rb +54 -0
- data/spec/api/gear_spec.rb +65 -0
- data/spec/api/key_spec.rb +54 -0
- data/spec/api/release_spec.rb +13 -0
- data/spec/api_spec_helper.rb +18 -0
- data/spec/references/data.yml +16 -0
- data/spec/seed.rb +70 -0
- data/spec/seedlog.log +1454 -0
- data/spec/support/vcr.rb +11 -0
- data/spec/vcr/Dawn_Account/_current/should_retrieve_current_user_account.yml +51 -0
- data/spec/vcr/Dawn_Account/_update/should_update_an_account.yml +99 -0
- data/spec/vcr/Dawn_App/_all/should_only_have_an_array_of_apps.yml +62 -0
- data/spec/vcr/Dawn_App/_all/should_retrieve_all_user_apps.yml +62 -0
- data/spec/vcr/Dawn_App/_create/should_create_a_new_app_given_a_name.yml +51 -0
- data/spec/vcr/Dawn_App/_create/should_raise_an_Excon_Errors_UnprocessableEntity_when_an_invalid_name_is_given.yml +49 -0
- data/spec/vcr/Dawn_App/_destroy/should_destroy_1_app.yml +49 -0
- data/spec/vcr/Dawn_App/_destroy/should_fail_to_destroy_non-existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_domains/should_have_domains.yml +51 -0
- data/spec/vcr/Dawn_App/_domains/should_retrieve_domains.yml +98 -0
- data/spec/vcr/Dawn_App/_drains/should_have_drains.yml +51 -0
- data/spec/vcr/Dawn_App/_find/should_fail_to_find_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_find/should_retrieve_1_app_by_id.yml +111 -0
- data/spec/vcr/Dawn_App/_find/should_retrieve_1_app_by_name.yml +51 -0
- data/spec/vcr/Dawn_App/_gears/should_have_gears.yml +51 -0
- data/spec/vcr/Dawn_App/_gears/should_restart_gears.yml +98 -0
- data/spec/vcr/Dawn_App/_gears/should_retrieve_gears.yml +98 -0
- data/spec/vcr/Dawn_App/_logs/should_fail_to_retrieve_logs_uri_for_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_logs/should_retrieve_logs_url_for_app.yml +98 -0
- data/spec/vcr/Dawn_App/_releases/should_have_releases.yml +51 -0
- data/spec/vcr/Dawn_App/_releases/should_retrieve_releases.yml +98 -0
- data/spec/vcr/Dawn_App/_restart/should_fail_to_restart_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_scale/should_have_updated_formation.yml +51 -0
- data/spec/vcr/Dawn_App/_scale/should_raise_an_IndexError_if_app_key_is_missing.yml +51 -0
- data/spec/vcr/Dawn_App/_scale/should_scale_app.yml +98 -0
- data/spec/vcr/Dawn_App/_update/should_fail_to_update_non-existant_app.yml +48 -0
- data/spec/vcr/Dawn_App_Domains/_all/should_have_only_domains.yml +98 -0
- data/spec/vcr/Dawn_App_Domains/_all/should_return_all_domains.yml +98 -0
- data/spec/vcr/Dawn_App_Domains/_create/should_create_a_new_domain.yml +99 -0
- data/spec/vcr/Dawn_App_Drains/_all/should_have_only_drains.yml +98 -0
- data/spec/vcr/Dawn_App_Drains/_all/should_return_all_drains.yml +98 -0
- data/spec/vcr/Dawn_App_Drains/_create/should_create_a_new_drain.yml +99 -0
- data/spec/vcr/Dawn_App_Gears/_all/should_return_all_gears.yml +98 -0
- data/spec/vcr/Dawn_App_Releases/_all/should_return_all_releases.yml +98 -0
- data/spec/vcr/Dawn_App_Releases/_create/should_create_a_new_release.yml +423 -0
- data/spec/vcr/Dawn_Key/_all/should_retrieve_all_user_keys.yml +52 -0
- data/spec/vcr/Dawn_Key/_create/should_create_a_new_sshkey.yml +51 -0
- data/spec/vcr/Dawn_Key/_create/should_fail_if_sshkey_is_invalid.yml +49 -0
- data/spec/vcr/Dawn_Key/_destroy/should_404_if_key_does_not_exist.yml +48 -0
- data/spec/vcr/Dawn_Key/_destroy/should_remove_a_key_by_id.yml +98 -0
- data/spec/vcr/Dawn_Key/_find/should_404_if_key_does_not_exist.yml +48 -0
- data/spec/vcr/Dawn_Key/_find/should_find_a_key_by_id.yml +99 -0
- data/spec/vcr/Dawn_Release/_find/should_find_1_release_by_id.yml +48 -0
- metadata +62 -3
- data/lib/dawn/api/safe.rb +0 -2
@@ -0,0 +1,54 @@
|
|
1
|
+
require "sshkey"
|
2
|
+
require 'api_spec_helper'
|
3
|
+
|
4
|
+
describe Dawn::Key, :vcr do
|
5
|
+
subject { Dawn::Key }
|
6
|
+
|
7
|
+
let(:testkey) { Dawn::Key.create key: SSHKey.generate.ssh_public_key }
|
8
|
+
|
9
|
+
it { should be_a Class }
|
10
|
+
|
11
|
+
describe ".create" do
|
12
|
+
it "should create a new sshkey" do
|
13
|
+
subject.create(key: SSHKey.generate.ssh_public_key)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should conflict if sshkey exists" do
|
17
|
+
expect { subject.create(key: testkey.key) }.to raise_error(Excon::Errors::UnprocessableEntity)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should fail if sshkey is invalid" do
|
21
|
+
expect { subject.create(key: "invalid key for the win") }.to raise_error(Excon::Errors::UnprocessableEntity)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".all" do
|
26
|
+
it "should retrieve all user keys" do
|
27
|
+
subject.all
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have only keys" do
|
31
|
+
subject.all.all? { |k| expect(k).to be_an_instance_of(Dawn::Key) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".find" do
|
36
|
+
it "should find a key by id" do
|
37
|
+
subject.find(id: testkey.id)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should 404 if key does not exist" do
|
41
|
+
expect { subject.find(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".destroy" do
|
46
|
+
it "should remove a key by id" do
|
47
|
+
subject.destroy(id: testkey.id)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should 404 if key does not exist" do
|
51
|
+
expect { subject.destroy(id: -1) }.to raise_error(Excon::Errors::NotFound)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
|
2
|
+
require "rspec"
|
3
|
+
require "rspec/expectations"
|
4
|
+
require "dawn/api"
|
5
|
+
require "ostruct"
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
$test_store = OpenStruct.new
|
9
|
+
$test_store.ref = YAML.load_file(File.expand_path("references/data.yml", File.dirname(__FILE__)))
|
10
|
+
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :rspec
|
15
|
+
config.color = true
|
16
|
+
config.formatter = :documentation
|
17
|
+
config.tty = true
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
apps:
|
3
|
+
drain-test: 5
|
4
|
+
gear-test: 7
|
5
|
+
release-test: 9
|
6
|
+
domains-test: 2
|
7
|
+
drains-test: 4
|
8
|
+
gears-test: 6
|
9
|
+
releases-test: 8
|
10
|
+
domain-test: 3
|
11
|
+
app-test: 15
|
12
|
+
env-test: 10
|
13
|
+
domains:
|
14
|
+
cc-rushers.io: 1
|
15
|
+
cookiecrushers.com: 2
|
16
|
+
cookie-crusher.net: 3
|
data/spec/seed.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
|
3
|
+
require "dawn/api"
|
4
|
+
require "yaml"
|
5
|
+
|
6
|
+
@seed_log = File.open("seedlog.log", "w")
|
7
|
+
@seed_log.sync = true
|
8
|
+
Dawn.log = @seed_log
|
9
|
+
|
10
|
+
@ref = YAML.load_file("references/data.yml") rescue {}
|
11
|
+
|
12
|
+
def reference(obj)
|
13
|
+
case obj
|
14
|
+
when Dawn::App
|
15
|
+
(@ref["apps"]||={})[obj.name] = obj.id
|
16
|
+
when Dawn::Domain
|
17
|
+
(@ref["domains"]||={})[obj.url] = obj.id
|
18
|
+
when Dawn::Drain
|
19
|
+
(@ref["drains"]||={})[obj.url] = obj.id
|
20
|
+
when Dawn::Gear
|
21
|
+
gears = (@ref["gears"]||={})
|
22
|
+
gears[gears.size] = obj.id
|
23
|
+
when Dawn::Release
|
24
|
+
releases = (@ref["releases"]||={})
|
25
|
+
releases[releases.size] = obj.id
|
26
|
+
end
|
27
|
+
p obj
|
28
|
+
end
|
29
|
+
|
30
|
+
if account = Dawn::Account.safe(:current)
|
31
|
+
reference account.safe(:update, account: { username: "IceDragon" })
|
32
|
+
end
|
33
|
+
Dawn.authenticate(username: "IceDragon", password: "creampuff")
|
34
|
+
|
35
|
+
reference Dawn::App.safe(:create, app: { name: "app-test" })
|
36
|
+
|
37
|
+
reference Dawn::App.safe(:create, app: { name: "domains-test" })
|
38
|
+
reference Dawn::App.safe(:create, app: { name: "domain-test" })
|
39
|
+
if app = Dawn::App.safe(:find, name: "domain-test")
|
40
|
+
reference app.domains.safe(:create, domain: { url: "cc-rushers.io" })
|
41
|
+
reference app.domains.safe(:create, domain: { url: "cookiecrushers.com" })
|
42
|
+
reference app.domains.safe(:create, domain: { url: "cookie-crusher.net" })
|
43
|
+
end
|
44
|
+
|
45
|
+
reference Dawn::App.safe(:create, app: { name: "drains-test" })
|
46
|
+
reference Dawn::App.safe(:create, app: { name: "drain-test" })
|
47
|
+
if app = Dawn::App.safe(:find, name: "drain-test")
|
48
|
+
reference app.drains.safe(:create, drain: { url: "flushme.io" })
|
49
|
+
reference app.drains.safe(:create, drain: { url: "toil.com" })
|
50
|
+
reference app.drains.safe(:create, drain: { url: "downthedrain.net" })
|
51
|
+
end
|
52
|
+
|
53
|
+
reference Dawn::App.safe(:create, app: { name: "gears-test" })
|
54
|
+
reference Dawn::App.safe(:create, app: { name: "gear-test" })
|
55
|
+
if app = Dawn::App.find(name: "gear-test")
|
56
|
+
#reference app.gears.safe(:create)
|
57
|
+
end
|
58
|
+
|
59
|
+
reference Dawn::App.safe(:create, app: { name: "releases-test" })
|
60
|
+
reference Dawn::App.safe(:create, app: { name: "release-test" })
|
61
|
+
if app = Dawn::App.find(name: "release-test")
|
62
|
+
reference app.releases.safe(:create, {})
|
63
|
+
end
|
64
|
+
|
65
|
+
reference Dawn::App.safe(:create, app: { name: "env-test" })
|
66
|
+
if app = Dawn::App.find(name: "env-test")
|
67
|
+
app.env.update({ "HOSTNAME" => "cookiesncode.io", "BREAD"=>"wheat" }).safe(:save)
|
68
|
+
end
|
69
|
+
|
70
|
+
File.write("references/data.yml", @ref.to_yaml)
|