This repository was archived by the owner on Jan 31, 2019. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathaws_ops_works_test.rb
More file actions
104 lines (85 loc) · 2.84 KB
/
Copy pathaws_ops_works_test.rb
File metadata and controls
104 lines (85 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
require File.expand_path('../helper', __FILE__)
class AwsOpsWorksTest < Service::TestCase
def setup
AWS.stub!
end
def test_stack_id_sent
response = service.receive_event
assert_equal sample_data['stack_id'], response.request_options[:stack_id]
end
def test_stack_id_missing
svc = service(sample_data.except('stack_id'))
assert_raises Service::ConfigurationError do
svc.receive_event
end
end
def test_app_id_sent
response = service.receive_event
assert_equal sample_data['app_id'], response.request_options[:app_id]
end
def test_app_id_missing
svc = service(sample_data.except('app_id'))
assert_raises Service::ConfigurationError do
svc.receive_event
end
end
def test_expected_branch_name_received
response = service.receive_event
refute_nil response
end
def test_unexpected_branch_name_received
response = service(sample_data, sample_payload('another-branch')).receive_event
assert_nil response
end
def test_branch_name_missing
svc = service(sample_data.except('branch_name'))
assert_raises Service::ConfigurationError do
svc.receive_event
end
end
def test_aws_access_key_id_configured
config = service.ops_works_client.config
assert_equal sample_data['aws_access_key_id'], config.access_key_id
end
def test_region_configured
config = service.ops_works_client.config
assert_equal sample_data['region'], config.ops_works_region
end
def test_aws_access_key_id_missing
svc = service(sample_data.except('aws_access_key_id'))
assert_raises Service::ConfigurationError do
svc.receive_event
end
end
def test_aws_secret_access_key_configured
config = service.ops_works_client.config
assert_equal sample_data['aws_secret_access_key'], config.secret_access_key
end
def test_aws_secret_access_key_missing
svc = service(sample_data.except('aws_secret_access_key'))
assert_raises Service::ConfigurationError do
svc.receive_event
end
end
def test_region_blank
svc = service(sample_data.merge('region' => ""))
config = service.ops_works_client.config
assert_equal sample_data['region'], config.ops_works_region
end
def service(data = sample_data, payload = sample_payload)
Service::AwsOpsWorks.new(:push, data, payload)
end
def sample_data
{
'aws_access_key_id' => 'AKIA1234567890123456',
'aws_secret_access_key' => '0123456789+0123456789+0123456789+0123456',
'stack_id' => '12345678-1234-1234-1234-123456789012',
'app_id' => '01234567-0123-0123-0123-012345678901',
'region' => "us-east-1",
'branch_name' => 'default-branch'
}
end
def sample_payload(branch_name = 'default-branch')
Service::PushHelpers.sample_payload.merge('ref' => "refs/heads/#{branch_name}")
end
end