vzcdn 0.2.2 → 0.2.3
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 -0
- data/lib/MockHttpResponse +6 -0
- data/lib/common.rb +22 -47
- data/lib/config_handler.rb +14 -3
- data/lib/http_send.rb +110 -0
- data/lib/method.rb +24 -3
- data/lib/mock_http_send.rb +15 -0
- data/lib/print.rb +5 -0
- data/lib/proxy_credentials.rb +5 -13
- data/lib/reporting.rb +105 -89
- data/lib/vzcdn.rb +16 -0
- data/lib/vzcdn/version.rb +1 -1
- data/lib/zone_update.rb +39 -0
- data/test/bad-credentials.mock +9 -0
- data/test/bad-credentials.results +8 -0
- data/test/create_delete.mock +72 -0
- data/test/crud.mock +44 -0
- data/test/crud.results +50 -0
- data/test/initial.mock +58 -0
- data/test/initial.results +308 -0
- data/test/mk_mock.rb +24 -0
- data/test/mk_response.rb +41 -0
- data/test/push.mock +58 -0
- data/test/test_clui.rb +34 -15
- data/test/test_mock.rb +282 -0
- data/test/test_reporting.rb +48 -47
- data/test/unreachable.mock +9 -0
- data/test/unreachable.results +8 -0
- data/vzcdn.gemspec +0 -2
- metadata +31 -19
- data/pkg/vzcdn-0.0.1.gem +0 -0
- data/test/test_all.rb +0 -2
data/test/mk_mock.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "readline"
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class Repl
|
5
|
+
def self.do
|
6
|
+
system("ec config set http-save-file #{$mockfile}")
|
7
|
+
system("rm .vdms.d/*.data")
|
8
|
+
while line = Readline.readline("> ", true)
|
9
|
+
if (line == "quit")
|
10
|
+
break
|
11
|
+
end
|
12
|
+
system(line)
|
13
|
+
end
|
14
|
+
puts "good day"
|
15
|
+
system("ec config delete http-save-file")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
base = ARGV.shift
|
20
|
+
$mockfile = base + '.mock'
|
21
|
+
if File.exist? $mockfile
|
22
|
+
FileUtils.rm $mockfile
|
23
|
+
end
|
24
|
+
Repl.do
|
data/test/mk_response.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "readline"
|
2
|
+
require 'test/unit'
|
3
|
+
require 'json'
|
4
|
+
require 'tempfile'
|
5
|
+
|
6
|
+
class Repl < MiniTest::Unit::TestCase
|
7
|
+
def test_repl
|
8
|
+
system("ec config set mock-env #{$mockfile}")
|
9
|
+
puts ""
|
10
|
+
file = File.open($outfile, "w")
|
11
|
+
file.puts("[")
|
12
|
+
while line = Readline.readline("> ", true)
|
13
|
+
if (line == "quit")
|
14
|
+
break
|
15
|
+
end
|
16
|
+
# p Readline::HISTORY.to_a
|
17
|
+
success = nil
|
18
|
+
FileUtils.cp($origfile, $watchfile)
|
19
|
+
out,err = capture_subprocess_io do
|
20
|
+
success = system(line)
|
21
|
+
end
|
22
|
+
diffout,differr = capture_subprocess_io do
|
23
|
+
system("diff #{$origfile} #{$watchfile}")
|
24
|
+
end
|
25
|
+
o = { cmd: line, stdout: out, stderr: err, diff: diffout}
|
26
|
+
file.puts(JSON.pretty_generate(o) + ',')
|
27
|
+
puts out
|
28
|
+
end
|
29
|
+
file.puts(" {} ]")
|
30
|
+
system("ec config delete mock-env")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
basename = ARGV.shift
|
35
|
+
$mockfile = basename + '.mock'
|
36
|
+
$outfile = basename + '.results'
|
37
|
+
$watchfile = 'zones/mockzone.5385'
|
38
|
+
file = Tempfile.new('cluitest')
|
39
|
+
$origfile = file.path
|
40
|
+
file.write(File.open($watchfile).read)
|
41
|
+
file.close
|
data/test/push.mock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"url": "https://api.edgecast.com/v2/mcc/customers/BED3/dns/routezones",
|
4
|
+
"method": "get",
|
5
|
+
"body": null,
|
6
|
+
"response_code": 200,
|
7
|
+
"response_body": "[{\"DomainName\":\"Daniel.Test.\",\"Status\":1,\"Version\":1400255085,\"ZoneId\":5389,\"ZoneType\":1},{\"DomainName\":\"mockzone.\",\"Status\":1,\"Version\":1400268405,\"ZoneId\":5385,\"ZoneType\":1},{\"DomainName\":\"nitin.\",\"Status\":1,\"Version\":1400096702,\"ZoneId\":5284,\"ZoneType\":1},{\"DomainName\":\"pythonzone.\",\"Status\":1,\"Version\":1400169998,\"ZoneId\":5366,\"ZoneType\":1},{\"DomainName\":\"vdmstest.com.\",\"Status\":1,\"Version\":1398108874,\"ZoneId\":4980,\"ZoneType\":1},{\"DomainName\":\"vzdms.com.\",\"Status\":1,\"Version\":1400510393,\"ZoneId\":5391,\"ZoneType\":2}]"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"url": "https://api.edgecast.com/v2/mcc//dns/routezonestatus",
|
11
|
+
"method": "get",
|
12
|
+
"body": null,
|
13
|
+
"response_code": 200,
|
14
|
+
"response_body": "[{\"Id\":1,\"Name\":\"Active\"},{\"Id\":2,\"Name\":\"Inactive\"}]"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"url": "https://api.edgecast.com/v2/mcc//dns/routezonetypes",
|
18
|
+
"method": "get",
|
19
|
+
"body": null,
|
20
|
+
"response_code": 200,
|
21
|
+
"response_body": "[{\"Id\":1,\"Name\":\"Primary\"},{\"Id\":2,\"Name\":\"Secondary\"}]"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"url": "https://api.edgecast.com/v2/mcc//dns/routehealthchecktypes",
|
25
|
+
"method": "get",
|
26
|
+
"body": null,
|
27
|
+
"response_code": 200,
|
28
|
+
"response_body": "[{\"Id\":1,\"Name\":\"HTTP\"},{\"Id\":2,\"Name\":\"HTTPs\"},{\"Id\":3,\"Name\":\"TCP Open\"},{\"Id\":4,\"Name\":\"TCP SSL\"}]"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"url": "https://api.edgecast.com/v2/mcc//dns/routehttpmethodtypes",
|
32
|
+
"method": "get",
|
33
|
+
"body": null,
|
34
|
+
"response_code": 200,
|
35
|
+
"response_body": "[{\"Id\":1,\"Name\":\"GET\"},{\"Id\":2,\"Name\":\"POST\"}]"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"url": "https://api.edgecast.com/v2/mcc//dns/routehealthcheckipversion",
|
39
|
+
"method": "get",
|
40
|
+
"body": null,
|
41
|
+
"response_code": 200,
|
42
|
+
"response_body": "[{\"Id\":1,\"Name\":\"IPv4\"},{\"Id\":2,\"Name\":\"IPv6\"}]"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"url": "https://api.edgecast.com/v2/mcc//dns/routereintegrationmethodtypes",
|
46
|
+
"method": "get",
|
47
|
+
"body": null,
|
48
|
+
"response_code": 200,
|
49
|
+
"response_body": "[{\"Id\":1,\"Name\":\"Automatic\"},{\"Id\":2,\"Name\":\"Manual\"}]"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"url": "https://api.edgecast.com/v2/mcc/customers/BED3/dns/routezone",
|
53
|
+
"method": "put",
|
54
|
+
"body": "{\n \"Comment\": \"\",\n \"DomainName\": \"mockzone.\",\n \"FailoverGroups\": [\n {\n \"Group\": {\n \"A\": [\n\n ],\n \"AAAA\": [\n\n ],\n \"CNAME\": [\n {\n \"HealthCheck\": null,\n \"IsPrimary\": true,\n \"Record\": {\n \"Name\": \"fo1\",\n \"Rdata\": \"www.google.com.mockzone.\",\n \"TTL\": 300\n }\n },\n {\n \"HealthCheck\": null,\n \"IsPrimary\": false,\n \"Record\": {\n \"Name\": \"fo1\",\n \"Rdata\": \"www.yahoo.com.mockzone.\",\n \"TTL\": 300\n }\n }\n ]\n },\n \"GroupTypeId\": 3,\n \"Name\": \"fo1\"\n }\n ],\n \"LoadBalancingGroups\": [\n {\n \"Group\": {\n \"A\": [\n {\n \"HealthCheck\": null,\n \"Weight\": 50,\n \"Record\": {\n \"Name\": \"lb1\",\n \"Rdata\": \"192.186.1.1\",\n \"TTL\": 300\n }\n },\n {\n \"HealthCheck\": null,\n \"Weight\": 50,\n \"Record\": {\n \"Name\": \"lb1\",\n \"Rdata\": \"192.186.2.2\",\n \"TTL\": 300\n }\n }\n ],\n \"AAAA\": [\n {\n \"HealthCheck\": {\n \"CheckInterval\": 60,\n \"CheckTypeId\": 1,\n \"ContentVerification\": \"\",\n \"EmailNotificationAddress\": \"a@b.c\",\n \"FailedCheckThreshold\": 4,\n \"HTTPMethodId\": null,\n \"IPAddress\": \"\",\n \"IPVersion\": 1,\n \"PortNumber\": null,\n \"ReintegrationMethodId\": 1,\n \"Status\": 2,\n \"StatusName\": \"Failed\",\n \"Uri\": \"www.google.com\"\n },\n \"Weight\": 50,\n \"Record\": {\n \"Name\": \"lb1\",\n \"Rdata\": \"2:2::\",\n \"TTL\": 300\n }\n },\n {\n \"HealthCheck\": {\n \"CheckInterval\": 60,\n \"CheckTypeId\": 1,\n \"ContentVerification\": \"\",\n \"EmailNotificationAddress\": \"a@b.c\",\n \"FailedCheckThreshold\": 4,\n \"HTTPMethodId\": null,\n \"IPAddress\": \"\",\n \"IPVersion\": 1,\n \"PortNumber\": null,\n \"ReintegrationMethodId\": 1,\n \"Status\": 2,\n \"StatusName\": \"Failed\",\n \"Uri\": \"www.yahoo.com\"\n },\n \"Weight\": 50,\n \"Record\": {\n \"Name\": \"lb1\",\n \"Rdata\": \"1:1::\",\n \"TTL\": 300\n }\n }\n ],\n \"CNAME\": [\n\n ]\n },\n \"GroupTypeId\": 3,\n \"Name\": \"lb1\"\n },\n {\n \"Group\": {\n \"A\": [\n {\n \"HealthCheck\": null,\n \"Weight\": 33,\n \"Record\": {\n \"Name\": \"lb2\",\n \"Rdata\": \"192.186.3.3\",\n \"TTL\": 300\n }\n },\n {\n \"HealthCheck\": null,\n \"Weight\": 33,\n \"Record\": {\n \"Name\": \"lb2\",\n \"Rdata\": \"192.186.4.4\",\n \"TTL\": 300\n }\n },\n {\n \"HealthCheck\": null,\n \"Weight\": 33,\n \"Record\": {\n \"Name\": \"lb2\",\n \"Rdata\": \"192.186.5.5\",\n \"TTL\": 300\n }\n }\n ],\n \"AAAA\": [\n\n ],\n \"CNAME\": [\n\n ]\n },\n \"GroupTypeId\": 3,\n \"Name\": \"lb2\"\n }\n ],\n \"Records\": {\n \"A\": [\n {\n \"Name\": \"@\",\n \"Rdata\": \"23.96.96.142\",\n \"TTL\": 4500\n },\n {\n \"Name\": \"portal\",\n \"Rdata\": \"65.196.119.145\",\n \"TTL\": 3600\n },\n {\n \"Name\": \"ops\",\n \"Rdata\": \"65.196.119.146\",\n \"TTL\": 3600\n },\n {\n \"Name\": \"sso\",\n \"Rdata\": \"65.196.119.147\",\n \"TTL\": 3600\n }\n ],\n \"AAAA\": [\n\n ],\n \"CNAME\": [\n {\n \"Name\": \"mockasia\",\n \"Rdata\": \"wpc.BED3.edgecastcdn.net.mockzone.\",\n \"TTL\": 3600\n },\n {\n \"Name\": \"mockeurope\",\n \"Rdata\": \"wpc.BED3.edgecastcdn.net.mockzone.\",\n \"TTL\": 3600\n },\n {\n \"Name\": \"www\",\n \"Rdata\": \"VZ-CDN-Learn-75038-site1.azurewebsites.net.mockzone.\",\n \"TTL\": 3600\n }\n ],\n \"MX\": [\n\n ],\n \"NS\": [\n\n ],\n \"SPF\": [\n\n ],\n \"SRV\": [\n\n ],\n \"TXT\": [\n\n ]\n },\n \"Status\": 1,\n \"Version\": 1400268405,\n \"ZoneId\": 5385,\n \"ZoneType\": 1\n}",
|
55
|
+
"response_code": 200,
|
56
|
+
"response_body": "{\"Comment\":\"\",\"DomainName\":\"mockzone.\",\"FailoverGroups\":[{\"Group\":{\"A\":[],\"AAAA\":[],\"CNAME\":[{\"HealthCheck\":null,\"IsPrimary\":true,\"Record\":{\"Name\":\"fo1\",\"Rdata\":\"www.google.com.mockzone.\",\"TTL\":300}},{\"HealthCheck\":null,\"IsPrimary\":false,\"Record\":{\"Name\":\"fo1\",\"Rdata\":\"www.yahoo.com.mockzone.\",\"TTL\":300}}]},\"GroupTypeId\":3,\"Name\":\"fo1\"}],\"LoadBalancingGroups\":[{\"Group\":{\"A\":[{\"HealthCheck\":null,\"Record\":{\"Name\":\"lb1\",\"Rdata\":\"192.186.1.1\",\"TTL\":300},\"Weight\":50},{\"HealthCheck\":null,\"Record\":{\"Name\":\"lb1\",\"Rdata\":\"192.186.2.2\",\"TTL\":300},\"Weight\":50}],\"AAAA\":[{\"HealthCheck\":{\"CheckInterval\":60,\"CheckTypeId\":1,\"ContentVerification\":\"\",\"EmailNotificationAddress\":\"a@b.c\",\"FailedCheckThreshold\":4,\"HTTPMethodId\":null,\"IPAddress\":\"\",\"IPVersion\":1,\"PortNumber\":null,\"ReintegrationMethodId\":1,\"Status\":4,\"StatusName\":\"Unknown\",\"Uri\":\"www.google.com\"},\"Record\":{\"Name\":\"lb1\",\"Rdata\":\"2:2::\",\"TTL\":300},\"Weight\":50},{\"HealthCheck\":{\"CheckInterval\":60,\"CheckTypeId\":1,\"ContentVerification\":\"\",\"EmailNotificationAddress\":\"a@b.c\",\"FailedCheckThreshold\":4,\"HTTPMethodId\":null,\"IPAddress\":\"\",\"IPVersion\":1,\"PortNumber\":null,\"ReintegrationMethodId\":1,\"Status\":4,\"StatusName\":\"Unknown\",\"Uri\":\"www.yahoo.com\"},\"Record\":{\"Name\":\"lb1\",\"Rdata\":\"1:1::\",\"TTL\":300},\"Weight\":50}],\"CNAME\":[]},\"GroupTypeId\":3,\"Name\":\"lb1\"},{\"Group\":{\"A\":[{\"HealthCheck\":null,\"Record\":{\"Name\":\"lb2\",\"Rdata\":\"192.186.3.3\",\"TTL\":300},\"Weight\":33},{\"HealthCheck\":null,\"Record\":{\"Name\":\"lb2\",\"Rdata\":\"192.186.4.4\",\"TTL\":300},\"Weight\":33},{\"HealthCheck\":null,\"Record\":{\"Name\":\"lb2\",\"Rdata\":\"192.186.5.5\",\"TTL\":300},\"Weight\":33}],\"AAAA\":[],\"CNAME\":[]},\"GroupTypeId\":3,\"Name\":\"lb2\"}],\"Records\":{\"A\":[{\"Name\":\"portal\",\"Rdata\":\"65.196.119.145\",\"TTL\":3600},{\"Name\":\"ops\",\"Rdata\":\"65.196.119.146\",\"TTL\":3600},{\"Name\":\"sso\",\"Rdata\":\"65.196.119.147\",\"TTL\":3600},{\"Name\":\"@\",\"Rdata\":\"23.96.96.142\",\"TTL\":4500}],\"AAAA\":[],\"CNAME\":[{\"Name\":\"mockasia\",\"Rdata\":\"wpc.BED3.edgecastcdn.net.mockzone.\",\"TTL\":3600},{\"Name\":\"mockeurope\",\"Rdata\":\"wpc.BED3.edgecastcdn.net.mockzone.\",\"TTL\":3600},{\"Name\":\"www\",\"Rdata\":\"VZ-CDN-Learn-75038-site1.azurewebsites.net.mockzone.\",\"TTL\":3600}],\"MX\":[],\"NS\":[],\"SPF\":[],\"SRV\":[],\"TXT\":[]},\"Status\":1,\"Version\":1400600570,\"ZoneId\":5385,\"ZoneType\":1}"
|
57
|
+
}
|
58
|
+
]
|
data/test/test_clui.rb
CHANGED
@@ -9,6 +9,7 @@ lib_dir = File.expand_path '../lib'
|
|
9
9
|
test_dir = File.expand_path '.'
|
10
10
|
$ruby_command = "ruby -I" + lib_dir + " " + bin_dir + "/ec "
|
11
11
|
$debug = 0
|
12
|
+
PROMPT = "~/VZCDNclui/vzcdn/lib $ ec "
|
12
13
|
|
13
14
|
# test_directory = Dir.mktmpdir "steve"
|
14
15
|
# Dir.chdir test_directory
|
@@ -35,16 +36,16 @@ class TestClui < MiniTest::Unit::TestCase
|
|
35
36
|
@@route = Route.do
|
36
37
|
end
|
37
38
|
|
38
|
-
def
|
39
|
+
def test_availables
|
39
40
|
@@route.get_available_zone_types
|
40
41
|
|
41
|
-
puts "record types:" + route.get_available_record_types.to_s
|
42
|
-
puts "zone status:" + route.get_available_zone_statuses.to_s
|
43
|
-
puts "route groups:" + route.get_available_route_groups.to_s
|
44
|
-
puts "http:" + route.get_available_http_methods.to_s
|
45
|
-
puts "ip vers:" + route.get_available_ip_versions.to_s
|
46
|
-
puts "hc types:" + route.get_available_health_check_types.to_s
|
47
|
-
puts "hc reints:" + route.get_available_health_check_reintegration_methods.to_s
|
42
|
+
puts "record types:" + @@route.get_available_record_types.to_s
|
43
|
+
puts "zone status:" + @@route.get_available_zone_statuses.to_s
|
44
|
+
puts "route groups:" + @@route.get_available_route_groups.to_s
|
45
|
+
puts "http:" + @@route.get_available_http_methods.to_s
|
46
|
+
puts "ip vers:" + @@route.get_available_ip_versions.to_s
|
47
|
+
puts "hc types:" + @@route.get_available_health_check_types.to_s
|
48
|
+
puts "hc reints:" + @@route.get_available_health_check_reintegration_methods.to_s
|
48
49
|
end
|
49
50
|
|
50
51
|
def call_ec(rest)
|
@@ -62,13 +63,9 @@ class TestClui < MiniTest::Unit::TestCase
|
|
62
63
|
|
63
64
|
def assert_ec_output(rest, expected_out)
|
64
65
|
out, err, success = call_ec_io(rest)
|
66
|
+
puts "\n\ntest output is: #{out}\n\n"
|
65
67
|
assert success, "'" + rest + "' failed"
|
66
|
-
|
67
|
-
assert_match expected_out, out.chomp, "'" + rest + "' failed"
|
68
|
-
else
|
69
|
-
assert_equal expected_out, out.chomp, "'" + rest + "' failed"
|
70
|
-
end
|
71
|
-
|
68
|
+
assert_equal expected_out.chomp, out.chomp, "'" + rest + "' failed"
|
72
69
|
assert_equal '', err.chomp, "'" + rest + "' printed to stderr:" + err
|
73
70
|
end
|
74
71
|
|
@@ -106,12 +103,34 @@ class TestClui < MiniTest::Unit::TestCase
|
|
106
103
|
File.delete(zone_file zone)
|
107
104
|
end
|
108
105
|
|
109
|
-
def
|
106
|
+
def test_pull_zone
|
110
107
|
get_zones
|
111
108
|
zone = @@zones.sample
|
112
109
|
name = zone["DomainName"]
|
113
110
|
assert_ec_output("zone #{name} pull", /saved locally/)
|
114
111
|
end
|
112
|
+
|
113
|
+
def test_transcript
|
114
|
+
File.open("transcript.txt") { |f|
|
115
|
+
response = ""
|
116
|
+
command = nil
|
117
|
+
f.each_line { |line|
|
118
|
+
if (line.index(PROMPT) == 0)
|
119
|
+
if (command && response)
|
120
|
+
puts "\n\ncommand is #{command}\n\n"
|
121
|
+
puts "\n\exepect_output is #{response}\n\n"
|
122
|
+
assert_ec_output(command, response)
|
123
|
+
puts "succeded test for command: #{command}"
|
124
|
+
end
|
125
|
+
command = line.sub(PROMPT,'')
|
126
|
+
response = ""
|
127
|
+
else
|
128
|
+
response += line
|
129
|
+
end
|
130
|
+
}
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
115
134
|
|
116
135
|
end
|
117
136
|
|
data/test/test_mock.rb
ADDED
@@ -0,0 +1,282 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'json'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
$test_dir = File.expand_path '.'
|
6
|
+
|
7
|
+
class TestMock < MiniTest::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@temp_dir = Dir.mktmpdir "steve"
|
10
|
+
Dir.chdir @temp_dir
|
11
|
+
system "ec config init BED3 asdf-sdfgds-fhdg-jhg-kja"
|
12
|
+
Dir.mkdir 'zones'
|
13
|
+
Dir.mkdir '.vdms.d/zones'
|
14
|
+
FileUtils.cp($origfile, $watchfile)
|
15
|
+
FileUtils.cp($origfile, ".vdms.d/#{$watchfile}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
FileUtils.remove_entry @temp_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
def check_patch(diffout)
|
23
|
+
FileUtils.cp($origfile, "t.t")
|
24
|
+
File.open("t.patch", "w") { |file|
|
25
|
+
file.write(diffout)
|
26
|
+
}
|
27
|
+
system "patch t.t t.patch > /dev/null"
|
28
|
+
rc = system "cmp --quiet t.t #{$watchfile}"
|
29
|
+
assert_equal rc, true, "#{$watchfile} doesn't match"
|
30
|
+
end
|
31
|
+
|
32
|
+
def results(command, out)
|
33
|
+
results = JSON.parse(File.open("#{$test_dir}/#{@mockbase}.results").read)
|
34
|
+
results.each { |result|
|
35
|
+
if result['cmd'] == command
|
36
|
+
if result['diff'] != ''
|
37
|
+
check_patch(result['diff'])
|
38
|
+
else
|
39
|
+
assert_equal result['stdout'], out, "output of command #{command} doesn't match"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def assert_side_effects(base, command)
|
46
|
+
@mockbase = base
|
47
|
+
system "ec config set mock-env #{$test_dir}/#{@mockbase}.mock"
|
48
|
+
out, err = capture_subprocess_io do
|
49
|
+
system(command)
|
50
|
+
end
|
51
|
+
obj = results(command, out)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_no_connection
|
55
|
+
assert_side_effects('unreachable', "ec zone list")
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_bad_credentials
|
59
|
+
assert_side_effects('bad-credentials', "ec zone list")
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_zone_list
|
63
|
+
assert_side_effects('initial', 'ec zone list')
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_pull
|
67
|
+
assert_side_effects('initial', 'ec zone mockzone pull')
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_pull_id
|
71
|
+
assert_side_effects('initial', 'ec zone 5385 pull')
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_ec_zone_mockzone
|
75
|
+
assert_side_effects('initial', 'ec zone mockzone')
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_ec_zone_5385
|
79
|
+
assert_side_effects('initial', 'ec zone 5385')
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_ec_zone_mockzone_rec
|
83
|
+
assert_side_effects('initial', 'ec zone mockzone rec')
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_ec_zone_mockzone_rec_a
|
87
|
+
assert_side_effects('initial', 'ec zone mockzone rec a')
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_ec_zone_mockzone_rec_a_cn
|
91
|
+
assert_side_effects('initial', 'ec zone mockzone rec a cn')
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_ec_zone_mockzone_rec_cn
|
95
|
+
assert_side_effects('initial', 'ec zone mockzone rec cn')
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_ec_zone_mockzone_rec_cn_print_h
|
99
|
+
assert_side_effects('initial', 'ec zone mockzone rec cn print -h')
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_ec_zone_mockzone_rec_cn_print_columns_Name_Rdata
|
103
|
+
assert_side_effects('initial', 'ec zone mockzone rec cn print --columns=Name,Rdata')
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_ec_zone_mockzone
|
107
|
+
assert_side_effects('initial', 'ec zone mockzone ')
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_ec_zone_mockzone_fail
|
111
|
+
assert_side_effects('initial', 'ec zone mockzone fail')
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_ec_zone_mockzone_fail_1_group
|
115
|
+
assert_side_effects('initial', 'ec zone mockzone fail 1 group')
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_ec_zone_mockzone_fail_1_group_cn
|
119
|
+
assert_side_effects('initial', 'ec zone mockzone fail 1 group cn')
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_ec_zone_mockzone_load
|
123
|
+
assert_side_effects('initial', 'ec zone mockzone load')
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_ec_zone_mockzone_load_1
|
127
|
+
assert_side_effects('initial', 'ec zone mockzone load 1')
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_ec_zone_mockzone_load_1_group
|
131
|
+
assert_side_effects('initial', 'ec zone mockzone load 1 group')
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_ec_zone_mockzone_load_1_group_a
|
135
|
+
assert_side_effects('initial', 'ec zone mockzone load 1 group a')
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_ec_zone_mockzone_load_1_group_aaaa
|
139
|
+
assert_side_effects('initial', 'ec zone mockzone load 1 group aaaa')
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_ec_zone_mockzone_load_1_group_aaaa
|
143
|
+
assert_side_effects('initial', 'ec zone mockzone load 1 group aaaa')
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_ec_zone_mockzone_load_1_group_aaaa_h
|
147
|
+
assert_side_effects('initial', 'ec zone mockzone load 1 group aaaa h')
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_ec_zone_mockzone_load_2
|
151
|
+
assert_side_effects('initial', 'ec zone mockzone load 2')
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_ec_zone_mockzone_load_2_group
|
155
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group')
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_ec_zone_mockzone_load_2_group_a
|
159
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a')
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_ec_zone_mockzone_load_2_group_a_print_j
|
163
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a print -j')
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_ec_zone_mockzone_load_2_group_a_print_h
|
167
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a print -h')
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_ec_zone_mockzone_load_2_group_a_print_tcsv
|
171
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a print -tcsv')
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_ec_zone_mockzone_load_2_group_a_print_tcsv_noheader
|
175
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a print -tcsv --no-header')
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_ec_zone_mockzone
|
179
|
+
assert_side_effects('initial', 'ec zone mockzone')
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_ec_zone_5385
|
183
|
+
assert_side_effects('initial', 'ec zone 5385')
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_ec_zone_5385_rec
|
187
|
+
assert_side_effects('initial', 'ec zone 5385 rec')
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_ec_zone_5385_rec_a
|
191
|
+
assert_side_effects('initial', 'ec zone 5385 rec a')
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_ec_zone_5385_rec_a_add
|
195
|
+
assert_side_effects('initial', 'ec zone 5385 rec a add')
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_ec_zone_5385_rec_a_add_figs_66_196_119_148_4500
|
199
|
+
assert_side_effects('initial', 'ec zone 5385 rec a add figs 66.196.119.148 4500')
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_ec_zone_mockzone
|
203
|
+
assert_side_effects('initial', 'ec zone mockzone')
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_ec_zone_mockzone_fail
|
207
|
+
assert_side_effects('initial', 'ec zone mockzone fail')
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_ec_zone_mockzone_fail_add
|
211
|
+
assert_side_effects('initial', 'ec zone mockzone fail add')
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_ec_zone_mockzone_fail_add_fo2_450
|
215
|
+
assert_side_effects('initial', 'ec zone mockzone fail add fo2 450')
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_ec_zone_mockzone_fail_2_group
|
219
|
+
assert_side_effects('initial', 'ec zone mockzone fail 2 group')
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_ec_zone_mockzone_fail_2
|
223
|
+
assert_side_effects('initial', 'ec zone mockzone fail 2 ')
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_ec_zone_mockzone_fail
|
227
|
+
assert_side_effects('initial', 'ec zone mockzone fail ')
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_ec_zone_mockzone_load
|
231
|
+
assert_side_effects('initial', 'ec zone mockzone load')
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_ec_zone_mockzone_load_2
|
235
|
+
assert_side_effects('initial', 'ec zone mockzone load 2')
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_ec_zone_mockzone_load_2_group
|
239
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group')
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_ec_zone_mockzone_load_2_group_a
|
243
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a')
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_ec_zone_mockzone_load_2_group_a_add
|
247
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a add')
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_ec_zone_mockzone_load_2_group_a_add_44_192_186_5_6
|
251
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a add 44 192.186.5.6')
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_ec_zone_mockzone_load_2_group_a_1
|
255
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a 1')
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_ec_zone_mockzone_load_2_group_a_1_sethc
|
259
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a 1 sethc')
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_ec_zone_mockzone_load_2_group_a_1_sethc_HTTPs
|
263
|
+
assert_side_effects('initial', 'ec zone mockzone load 2 group a 1 sethc HTTPs www.google.com IPv6 300 2 s.c@v.com')
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_crud_ec_zone
|
267
|
+
assert_side_effects('crud', 'ec zone')
|
268
|
+
assert_side_effects('crud', 'ec zone create -h')
|
269
|
+
assert_side_effects('crud', 'ec zone create deleteme Active')
|
270
|
+
assert_side_effects('crud', 'ec zone deleteme ')
|
271
|
+
assert_side_effects('crud', 'ec zone deleteme rec')
|
272
|
+
assert_side_effects('crud', 'ec zone deleteme rec a add images 196.244.5.1 3500')
|
273
|
+
assert_side_effects('crud', 'ec zone deleteme push')
|
274
|
+
assert_side_effects('crud', 'ec zone deleteme delete')
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
$watchfile = 'zones/mockzone.5385'
|
279
|
+
file = Tempfile.new('cluitest')
|
280
|
+
$origfile = file.path
|
281
|
+
file.write(File.open($watchfile).read)
|
282
|
+
file.close
|