brightbox-cli 5.0.0.alpha → 5.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -1
- data/CHANGELOG.md +60 -0
- data/Gemfile.lock +1 -1
- data/lib/brightbox-cli/accounts.rb +5 -1
- data/lib/brightbox-cli/api.rb +34 -1
- data/lib/brightbox-cli/cloud_ips.rb +6 -6
- data/lib/brightbox-cli/collaboration.rb +3 -7
- data/lib/brightbox-cli/commands/lbs/create.rb +0 -2
- data/lib/brightbox-cli/commands/lbs/show.rb +4 -0
- data/lib/brightbox-cli/config.rb +10 -4
- data/lib/brightbox-cli/database_server.rb +20 -20
- data/lib/brightbox-cli/database_snapshot.rb +5 -5
- data/lib/brightbox-cli/database_type.rb +4 -8
- data/lib/brightbox-cli/detailed_server.rb +26 -28
- data/lib/brightbox-cli/detailed_server_group.rb +2 -2
- data/lib/brightbox-cli/firewall_policy.rb +5 -9
- data/lib/brightbox-cli/firewall_rule.rb +14 -15
- data/lib/brightbox-cli/images.rb +22 -21
- data/lib/brightbox-cli/indifferent_access_hash.rb +50 -0
- data/lib/brightbox-cli/load_balancers.rb +27 -11
- data/lib/brightbox-cli/server_groups.rb +4 -8
- data/lib/brightbox-cli/servers.rb +22 -16
- data/lib/brightbox-cli/types.rb +4 -8
- data/lib/brightbox-cli/user_collaboration.rb +1 -1
- data/lib/brightbox-cli/users.rb +3 -5
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox-cli/volume.rb +9 -13
- data/lib/brightbox-cli/zones.rb +0 -4
- data/lib/brightbox_cli.rb +1 -0
- data/spec/commands/cloudips/update_spec.rb +7 -5
- data/spec/commands/configmaps/create_spec.rb +6 -6
- data/spec/commands/configmaps/destroy_spec.rb +1 -1
- data/spec/commands/configmaps/list_spec.rb +1 -1
- data/spec/commands/configmaps/show_spec.rb +3 -3
- data/spec/commands/configmaps/update_spec.rb +9 -9
- data/spec/commands/lbs/create_spec.rb +12 -26
- data/spec/commands/lbs/show_spec.rb +15 -3
- data/spec/commands/lbs/update_spec.rb +4 -4
- data/spec/commands/servers/update_spec.rb +7 -7
- data/spec/commands/sql/instances/create_spec.rb +8 -8
- data/spec/commands/sql/instances/reset_spec.rb +3 -3
- data/spec/commands/sql/instances/resize_spec.rb +4 -4
- data/spec/commands/sql/instances/show_spec.rb +2 -1
- data/spec/commands/sql/instances/update_spec.rb +3 -3
- data/spec/commands/sql/snapshots/list_spec.rb +1 -1
- data/spec/commands/sql/snapshots/show_spec.rb +50 -7
- data/spec/commands/volumes/attach_spec.rb +4 -4
- data/spec/commands/volumes/copy_spec.rb +2 -2
- data/spec/commands/volumes/destroy_spec.rb +1 -1
- data/spec/commands/volumes/detach_spec.rb +1 -1
- data/spec/commands/volumes/list_spec.rb +1 -1
- data/spec/commands/volumes/resize_spec.rb +3 -3
- data/spec/commands/volumes/show_spec.rb +1 -1
- data/spec/commands/volumes/update_spec.rb +4 -4
- data/spec/spec_helper.rb +14 -10
- data/spec/support/shared/api_resource_examples.rb +25 -0
- data/spec/unit/brightbox/account/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/api/attributes_spec.rb +65 -0
- data/spec/unit/brightbox/api/fog_attributes_spec.rb +65 -0
- data/spec/unit/brightbox/cloud_ip/attributes_spec.rb +19 -0
- data/spec/unit/brightbox/collaborating_account/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/database_server/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/database_snapshot/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/database_type/attributes_spec.rb +20 -0
- data/spec/unit/brightbox/detailed_server/attributes_spec.rb +29 -0
- data/spec/unit/brightbox/detailed_server_group/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/firewall_policy/attributes_spec.rb +21 -0
- data/spec/unit/brightbox/firewall_rule/attributes_spec.rb +18 -0
- data/spec/unit/brightbox/image/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/image/status_spec.rb +67 -0
- data/spec/unit/brightbox/load_balancer/acme_cert_spec.rb +75 -0
- data/spec/unit/brightbox/load_balancer/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/load_balancer/formatted_acme_domains_spec.rb +78 -0
- data/spec/unit/brightbox/server/attributes_spec.rb +29 -0
- data/spec/unit/brightbox/server_group/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/type/attributes_spec.rb +20 -0
- data/spec/unit/brightbox/user/attributes_spec.rb +13 -0
- data/spec/unit/brightbox/user_collaboration/attributes_spec.rb +13 -0
- metadata +47 -4
- data/spec/cassettes/brightbox_sql_snapshots/show/when_resource_exists/does_not_output_to_stderr.yml +0 -93
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::Api, "#fog_attributes" do
|
4
|
+
subject(:model_attributes) { api_model.fog_attributes }
|
5
|
+
|
6
|
+
let(:api_model) { Brightbox::Api.new(fog_model) }
|
7
|
+
let(:fog_model) do
|
8
|
+
double(
|
9
|
+
"Fog::Compute::Brightbox::Api",
|
10
|
+
id: "res-12345",
|
11
|
+
attributes: attributes
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when attributes are not set" do
|
16
|
+
let(:attributes) { nil }
|
17
|
+
|
18
|
+
it "returns an indifferent access hash" do
|
19
|
+
expect(model_attributes).to be_instance_of(IndifferentAccessHash)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when attributes are set with a mix of string and symbols" do
|
24
|
+
let(:attributes) do
|
25
|
+
{
|
26
|
+
id: "res-12345",
|
27
|
+
name: "test",
|
28
|
+
acme: acme_details
|
29
|
+
}
|
30
|
+
end
|
31
|
+
let(:acme_details) do
|
32
|
+
{
|
33
|
+
"domains" => [
|
34
|
+
{
|
35
|
+
"identifier" => "example.test",
|
36
|
+
"status" => "pending"
|
37
|
+
}
|
38
|
+
]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
it "transforms the keys with deep symbolize" do
|
43
|
+
expect(model_attributes).to eq(
|
44
|
+
id: "res-12345",
|
45
|
+
name: "test",
|
46
|
+
acme: {
|
47
|
+
domains: [
|
48
|
+
{
|
49
|
+
identifier: "example.test",
|
50
|
+
status: "pending"
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "can not accessed by string keys" do
|
58
|
+
expect(model_attributes["acme"]["domains"].first["identifier"]).to eq("example.test")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "can accessed by symbol keys" do
|
62
|
+
expect(model_attributes[:acme][:domains].first[:identifier]).to eq("example.test")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::CloudIP, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Model",
|
9
|
+
id: "cip-12345",
|
10
|
+
destination_id: nil,
|
11
|
+
attributes: model_attributes
|
12
|
+
)
|
13
|
+
end
|
14
|
+
let(:model_attributes) { { id: "cip-12345" } }
|
15
|
+
|
16
|
+
it "returns an IndifferentAccessHash" do
|
17
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::CollaboratingAccount, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::DatabaseServer, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::DatabaseSnapshot, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::DatabaseType, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Model",
|
9
|
+
id: "typ-12345",
|
10
|
+
attributes: model_attributes,
|
11
|
+
ram: 1024,
|
12
|
+
disk: 10_240,
|
13
|
+
)
|
14
|
+
end
|
15
|
+
let(:model_attributes) { { id: "typ-12345" } }
|
16
|
+
|
17
|
+
it "returns an IndifferentAccessHash" do
|
18
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::DetailedServer, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Model",
|
9
|
+
id: "srv-12345",
|
10
|
+
attributes: model_attributes,
|
11
|
+
cloud_ips: [],
|
12
|
+
created_at: Time.parse("2025-01-01T12:00:00Z"),
|
13
|
+
created_on: "2025-01-01",
|
14
|
+
hostname: "srv-12345.gb1.brightbox.com",
|
15
|
+
image_id: "img-12345",
|
16
|
+
interfaces: [],
|
17
|
+
locked?: false,
|
18
|
+
type: "typ-12345",
|
19
|
+
state: "active",
|
20
|
+
server_type: "typ-12345",
|
21
|
+
zone: { id: "zon-12345", handle: "gb1-a" }
|
22
|
+
)
|
23
|
+
end
|
24
|
+
let(:model_attributes) { { id: "srv-12345" } }
|
25
|
+
|
26
|
+
it "returns an IndifferentAccessHash" do
|
27
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::DetailedServerGroup, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::FirewallPolicy, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Model",
|
9
|
+
id: "res-12345",
|
10
|
+
attributes: model_attributes,
|
11
|
+
description: "",
|
12
|
+
server_group_id: "grp-12345",
|
13
|
+
name: "my-policy"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
let(:model_attributes) { { id: "fwp-12345" } }
|
17
|
+
|
18
|
+
it "returns an IndifferentAccessHash" do
|
19
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::FirewallRule, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Model",
|
9
|
+
id: "fwr-12345",
|
10
|
+
attributes: model_attributes
|
11
|
+
)
|
12
|
+
end
|
13
|
+
let(:model_attributes) { { id: "fwr-12345" } }
|
14
|
+
|
15
|
+
it "returns an IndifferentAccessHash" do
|
16
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::Image, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::Image, "#status" do
|
4
|
+
subject(:image) { Brightbox::Image.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Compute::Brightbox::Image",
|
9
|
+
id: "img-12345",
|
10
|
+
attributes: {
|
11
|
+
"id": "img-12345",
|
12
|
+
"status": status,
|
13
|
+
"public": is_public
|
14
|
+
},
|
15
|
+
public: is_public
|
16
|
+
)
|
17
|
+
end
|
18
|
+
let(:is_public) { false }
|
19
|
+
|
20
|
+
context "when the image is pending" do
|
21
|
+
let(:status) { "pending" }
|
22
|
+
|
23
|
+
it "returns 'pending'" do
|
24
|
+
expect(image.status).to eq("pending")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the image is available" do
|
29
|
+
let(:status) { "available" }
|
30
|
+
|
31
|
+
context "with public visibility" do
|
32
|
+
let(:is_public) { true }
|
33
|
+
|
34
|
+
it "returns 'public'" do
|
35
|
+
expect(image.status).to eq("public")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "without public visibility" do
|
40
|
+
let(:is_public) { false }
|
41
|
+
|
42
|
+
it "returns 'private'" do
|
43
|
+
expect(image.status).to eq("private")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when the image is deprecated" do
|
49
|
+
let(:status) { "deprecated" }
|
50
|
+
|
51
|
+
context "with public visibility" do
|
52
|
+
let(:is_public) { true }
|
53
|
+
|
54
|
+
it "returns 'deprecated'" do
|
55
|
+
expect(image.status).to eq("deprecated")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "without public visibility" do
|
60
|
+
let(:is_public) { false }
|
61
|
+
|
62
|
+
it "returns 'private'" do
|
63
|
+
expect(image.status).to eq("private")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::LoadBalancer, "#acme_cert" do
|
4
|
+
subject(:acme_cert) { load_balancer.acme_cert }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Compute::Brightbox::LoadBalancer",
|
9
|
+
id: "lba-12345",
|
10
|
+
attributes: lba_attributes
|
11
|
+
)
|
12
|
+
end
|
13
|
+
let(:load_balancer) { Brightbox::LoadBalancer.new(fog_model) }
|
14
|
+
|
15
|
+
context "when ACME is not setup" do
|
16
|
+
let(:lba_attributes) { { acme: nil } }
|
17
|
+
|
18
|
+
it "returns an empty string" do
|
19
|
+
expect(acme_cert).not_to be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when ACME is setup" do
|
24
|
+
context "without certificate" do
|
25
|
+
let(:lba_attributes) do
|
26
|
+
{ acme: { certificate: nil }}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns an object without keys" do
|
30
|
+
expect(acme_cert).not_to be_nil
|
31
|
+
|
32
|
+
expect(acme_cert).to have_attributes(
|
33
|
+
expires_at: "",
|
34
|
+
fingerprint: "",
|
35
|
+
issued_at: "",
|
36
|
+
subjects: ""
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with certificate" do
|
42
|
+
let(:expected_formatting) { "example.com:verified,example.net:pending" }
|
43
|
+
let(:lba_attributes) do
|
44
|
+
{
|
45
|
+
acme: {
|
46
|
+
domains: [
|
47
|
+
{ identifier: "domain.one.test", status: "verified" },
|
48
|
+
{ identifier: "domain.two.test", status: "verified" }
|
49
|
+
],
|
50
|
+
certificate: {
|
51
|
+
domains: [
|
52
|
+
"domain.one.test",
|
53
|
+
"domain.two.test"
|
54
|
+
],
|
55
|
+
expires_at: "2025-12-31T23:59:59Z",
|
56
|
+
fingerprint: "TLS-fingerprint",
|
57
|
+
issued_at: "2025-01-01T00:00:00Z"
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns an object with the correct keys" do
|
64
|
+
expect(acme_cert).not_to be_nil
|
65
|
+
|
66
|
+
expect(acme_cert).to have_attributes(
|
67
|
+
expires_at: "2025-12-31T23:59:59Z",
|
68
|
+
fingerprint: "TLS-fingerprint",
|
69
|
+
issued_at: "2025-01-01T00:00:00Z",
|
70
|
+
subjects: "domain.one.test,domain.two.test"
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::LoadBalancer, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::LoadBalancer, "#formatted_acme_domains" do
|
4
|
+
subject(:load_balancer) { Brightbox::LoadBalancer.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Compute::Brightbox::LoadBalancer",
|
9
|
+
id: "lba-12345",
|
10
|
+
attributes: lba_attributes
|
11
|
+
)
|
12
|
+
end
|
13
|
+
let(:lba_attributes) do
|
14
|
+
# Encode/decode JSON to get final key/value forms
|
15
|
+
JSON.parse({
|
16
|
+
id: "lba-12345",
|
17
|
+
acme: acme_details
|
18
|
+
}.to_json)
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when ACME is not setup" do
|
22
|
+
let(:acme_details) { nil }
|
23
|
+
|
24
|
+
it "returns an empty array" do
|
25
|
+
expect(load_balancer.formatted_acme_domains).to eq("")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when no domains are returned" do
|
30
|
+
let(:acme_details) do
|
31
|
+
{ domains: [] }
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns an empty array" do
|
35
|
+
expect(load_balancer.formatted_acme_domains).to eq("")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when multiple domains are returned" do
|
40
|
+
let(:acme_details) do
|
41
|
+
{
|
42
|
+
domains: [
|
43
|
+
{
|
44
|
+
identifier: "example.com",
|
45
|
+
status: "verified"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
identifier: "example.net",
|
49
|
+
status: "pending"
|
50
|
+
}
|
51
|
+
]
|
52
|
+
}
|
53
|
+
end
|
54
|
+
let(:expected_formatting) do
|
55
|
+
"example.com:verified,example.net:pending"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns a comma separated list of domains and statuses" do
|
59
|
+
expect(load_balancer.formatted_acme_domains).to eq(expected_formatting)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when error occurs" do
|
64
|
+
let(:lba_attributes) do
|
65
|
+
# Encode/decode JSON to get final key/value forms
|
66
|
+
JSON.parse({
|
67
|
+
id: "lba-12345",
|
68
|
+
acme: {
|
69
|
+
domains: nil
|
70
|
+
}
|
71
|
+
}.to_json)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns an empty array" do
|
75
|
+
expect(load_balancer.formatted_acme_domains).to eq("")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::Server, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Model",
|
9
|
+
id: "srv-12345",
|
10
|
+
attributes: model_attributes,
|
11
|
+
cloud_ips: [],
|
12
|
+
created_at: Time.parse("2025-01-01T12:00:00Z"),
|
13
|
+
created_on: "2025-01-01",
|
14
|
+
hostname: "srv-12345.gb1.brightbox.com",
|
15
|
+
image_id: "img-12345",
|
16
|
+
interfaces: [],
|
17
|
+
locked?: false,
|
18
|
+
type: "typ-12345",
|
19
|
+
state: "active",
|
20
|
+
server_type: "typ-12345",
|
21
|
+
zone: { id: "zon-12345", handle: "gb1-a" }
|
22
|
+
)
|
23
|
+
end
|
24
|
+
let(:model_attributes) { { id: "srv-12345" } }
|
25
|
+
|
26
|
+
it "returns an IndifferentAccessHash" do
|
27
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::ServerGroup, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::Type, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double(
|
8
|
+
"Fog::Model",
|
9
|
+
id: "typ-12345",
|
10
|
+
attributes: model_attributes,
|
11
|
+
ram: 1_024,
|
12
|
+
disk: 10_240
|
13
|
+
)
|
14
|
+
end
|
15
|
+
let(:model_attributes) { { id: "typ-12345" } }
|
16
|
+
|
17
|
+
it "returns an IndifferentAccessHash" do
|
18
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::User, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Brightbox::UserCollaboration, "#attributes" do
|
4
|
+
subject { described_class.new(fog_model) }
|
5
|
+
|
6
|
+
let(:fog_model) do
|
7
|
+
double("Fog::Model", id: "res-12345", attributes: { id: "res-12345"})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an IndifferentAccessHash" do
|
11
|
+
expect(subject.attributes).to be_a(IndifferentAccessHash)
|
12
|
+
end
|
13
|
+
end
|