right_agent 2.0.7-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +82 -0
- data/Rakefile +113 -0
- data/lib/right_agent.rb +59 -0
- data/lib/right_agent/actor.rb +182 -0
- data/lib/right_agent/actor_registry.rb +76 -0
- data/lib/right_agent/actors/agent_manager.rb +232 -0
- data/lib/right_agent/agent.rb +1149 -0
- data/lib/right_agent/agent_config.rb +480 -0
- data/lib/right_agent/agent_identity.rb +210 -0
- data/lib/right_agent/agent_tag_manager.rb +237 -0
- data/lib/right_agent/audit_formatter.rb +107 -0
- data/lib/right_agent/clients.rb +31 -0
- data/lib/right_agent/clients/api_client.rb +383 -0
- data/lib/right_agent/clients/auth_client.rb +247 -0
- data/lib/right_agent/clients/balanced_http_client.rb +369 -0
- data/lib/right_agent/clients/base_retry_client.rb +495 -0
- data/lib/right_agent/clients/right_http_client.rb +279 -0
- data/lib/right_agent/clients/router_client.rb +493 -0
- data/lib/right_agent/command.rb +30 -0
- data/lib/right_agent/command/agent_manager_commands.rb +150 -0
- data/lib/right_agent/command/command_client.rb +136 -0
- data/lib/right_agent/command/command_constants.rb +33 -0
- data/lib/right_agent/command/command_io.rb +126 -0
- data/lib/right_agent/command/command_parser.rb +87 -0
- data/lib/right_agent/command/command_runner.rb +118 -0
- data/lib/right_agent/command/command_serializer.rb +63 -0
- data/lib/right_agent/connectivity_checker.rb +179 -0
- data/lib/right_agent/console.rb +65 -0
- data/lib/right_agent/core_payload_types.rb +44 -0
- data/lib/right_agent/core_payload_types/cookbook.rb +61 -0
- data/lib/right_agent/core_payload_types/cookbook_position.rb +46 -0
- data/lib/right_agent/core_payload_types/cookbook_repository.rb +116 -0
- data/lib/right_agent/core_payload_types/cookbook_sequence.rb +70 -0
- data/lib/right_agent/core_payload_types/dev_repositories.rb +100 -0
- data/lib/right_agent/core_payload_types/dev_repository.rb +76 -0
- data/lib/right_agent/core_payload_types/event_categories.rb +38 -0
- data/lib/right_agent/core_payload_types/executable_bundle.rb +130 -0
- data/lib/right_agent/core_payload_types/login_policy.rb +72 -0
- data/lib/right_agent/core_payload_types/login_user.rb +79 -0
- data/lib/right_agent/core_payload_types/planned_volume.rb +94 -0
- data/lib/right_agent/core_payload_types/recipe_instantiation.rb +73 -0
- data/lib/right_agent/core_payload_types/repositories_bundle.rb +50 -0
- data/lib/right_agent/core_payload_types/right_script_attachment.rb +95 -0
- data/lib/right_agent/core_payload_types/right_script_instantiation.rb +94 -0
- data/lib/right_agent/core_payload_types/runlist_policy.rb +44 -0
- data/lib/right_agent/core_payload_types/secure_document.rb +66 -0
- data/lib/right_agent/core_payload_types/secure_document_location.rb +63 -0
- data/lib/right_agent/core_payload_types/software_repository_instantiation.rb +61 -0
- data/lib/right_agent/daemonize.rb +35 -0
- data/lib/right_agent/dispatched_cache.rb +109 -0
- data/lib/right_agent/dispatcher.rb +272 -0
- data/lib/right_agent/enrollment_result.rb +221 -0
- data/lib/right_agent/exceptions.rb +87 -0
- data/lib/right_agent/history.rb +145 -0
- data/lib/right_agent/log.rb +460 -0
- data/lib/right_agent/minimal.rb +46 -0
- data/lib/right_agent/monkey_patches.rb +30 -0
- data/lib/right_agent/monkey_patches/ruby_patch.rb +55 -0
- data/lib/right_agent/monkey_patches/ruby_patch/array_patch.rb +29 -0
- data/lib/right_agent/monkey_patches/ruby_patch/darwin_patch.rb +24 -0
- data/lib/right_agent/monkey_patches/ruby_patch/linux_patch.rb +24 -0
- data/lib/right_agent/monkey_patches/ruby_patch/linux_patch/file_patch.rb +30 -0
- data/lib/right_agent/monkey_patches/ruby_patch/object_patch.rb +49 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch.rb +32 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/file_patch.rb +60 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/process_patch.rb +63 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/stdio_patch.rb +27 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/time_patch.rb +55 -0
- data/lib/right_agent/monkey_patches/ruby_patch/windows_patch/win32ole_patch.rb +34 -0
- data/lib/right_agent/multiplexer.rb +102 -0
- data/lib/right_agent/offline_handler.rb +270 -0
- data/lib/right_agent/operation_result.rb +300 -0
- data/lib/right_agent/packets.rb +673 -0
- data/lib/right_agent/payload_formatter.rb +104 -0
- data/lib/right_agent/pending_requests.rb +128 -0
- data/lib/right_agent/pid_file.rb +159 -0
- data/lib/right_agent/platform.rb +770 -0
- data/lib/right_agent/platform/unix/darwin/platform.rb +102 -0
- data/lib/right_agent/platform/unix/linux/platform.rb +305 -0
- data/lib/right_agent/platform/unix/platform.rb +226 -0
- data/lib/right_agent/platform/windows/mingw/platform.rb +447 -0
- data/lib/right_agent/platform/windows/mswin/platform.rb +236 -0
- data/lib/right_agent/platform/windows/platform.rb +1808 -0
- data/lib/right_agent/protocol_version_mixin.rb +69 -0
- data/lib/right_agent/retryable_request.rb +195 -0
- data/lib/right_agent/scripts/agent_controller.rb +543 -0
- data/lib/right_agent/scripts/agent_deployer.rb +400 -0
- data/lib/right_agent/scripts/common_parser.rb +160 -0
- data/lib/right_agent/scripts/log_level_manager.rb +192 -0
- data/lib/right_agent/scripts/stats_manager.rb +268 -0
- data/lib/right_agent/scripts/usage.rb +58 -0
- data/lib/right_agent/secure_identity.rb +92 -0
- data/lib/right_agent/security.rb +32 -0
- data/lib/right_agent/security/cached_certificate_store_proxy.rb +77 -0
- data/lib/right_agent/security/certificate.rb +102 -0
- data/lib/right_agent/security/certificate_cache.rb +89 -0
- data/lib/right_agent/security/distinguished_name.rb +56 -0
- data/lib/right_agent/security/encrypted_document.rb +83 -0
- data/lib/right_agent/security/rsa_key_pair.rb +76 -0
- data/lib/right_agent/security/signature.rb +86 -0
- data/lib/right_agent/security/static_certificate_store.rb +85 -0
- data/lib/right_agent/sender.rb +792 -0
- data/lib/right_agent/serialize.rb +29 -0
- data/lib/right_agent/serialize/message_pack.rb +107 -0
- data/lib/right_agent/serialize/secure_serializer.rb +151 -0
- data/lib/right_agent/serialize/secure_serializer_initializer.rb +47 -0
- data/lib/right_agent/serialize/serializable.rb +151 -0
- data/lib/right_agent/serialize/serializer.rb +159 -0
- data/lib/right_agent/subprocess.rb +38 -0
- data/lib/right_agent/tracer.rb +124 -0
- data/right_agent.gemspec +101 -0
- data/spec/actor_registry_spec.rb +80 -0
- data/spec/actor_spec.rb +162 -0
- data/spec/agent_config_spec.rb +235 -0
- data/spec/agent_identity_spec.rb +78 -0
- data/spec/agent_spec.rb +734 -0
- data/spec/agent_tag_manager_spec.rb +319 -0
- data/spec/clients/api_client_spec.rb +423 -0
- data/spec/clients/auth_client_spec.rb +272 -0
- data/spec/clients/balanced_http_client_spec.rb +576 -0
- data/spec/clients/base_retry_client_spec.rb +635 -0
- data/spec/clients/router_client_spec.rb +594 -0
- data/spec/clients/spec_helper.rb +111 -0
- data/spec/command/agent_manager_commands_spec.rb +51 -0
- data/spec/command/command_io_spec.rb +93 -0
- data/spec/command/command_parser_spec.rb +79 -0
- data/spec/command/command_runner_spec.rb +107 -0
- data/spec/command/command_serializer_spec.rb +51 -0
- data/spec/connectivity_checker_spec.rb +83 -0
- data/spec/core_payload_types/dev_repositories_spec.rb +64 -0
- data/spec/core_payload_types/dev_repository_spec.rb +33 -0
- data/spec/core_payload_types/executable_bundle_spec.rb +67 -0
- data/spec/core_payload_types/login_user_spec.rb +102 -0
- data/spec/core_payload_types/recipe_instantiation_spec.rb +81 -0
- data/spec/core_payload_types/right_script_attachment_spec.rb +65 -0
- data/spec/core_payload_types/right_script_instantiation_spec.rb +79 -0
- data/spec/core_payload_types/spec_helper.rb +23 -0
- data/spec/dispatched_cache_spec.rb +136 -0
- data/spec/dispatcher_spec.rb +324 -0
- data/spec/enrollment_result_spec.rb +53 -0
- data/spec/history_spec.rb +246 -0
- data/spec/log_spec.rb +192 -0
- data/spec/monkey_patches/eventmachine_spec.rb +62 -0
- data/spec/multiplexer_spec.rb +48 -0
- data/spec/offline_handler_spec.rb +340 -0
- data/spec/operation_result_spec.rb +208 -0
- data/spec/packets_spec.rb +461 -0
- data/spec/pending_requests_spec.rb +136 -0
- data/spec/platform/spec_helper.rb +216 -0
- data/spec/platform/unix/darwin/platform_spec.rb +181 -0
- data/spec/platform/unix/linux/platform_spec.rb +540 -0
- data/spec/platform/unix/spec_helper.rb +149 -0
- data/spec/platform/windows/mingw/platform_spec.rb +222 -0
- data/spec/platform/windows/mswin/platform_spec.rb +259 -0
- data/spec/platform/windows/spec_helper.rb +720 -0
- data/spec/retryable_request_spec.rb +306 -0
- data/spec/secure_identity_spec.rb +50 -0
- data/spec/security/cached_certificate_store_proxy_spec.rb +62 -0
- data/spec/security/certificate_cache_spec.rb +71 -0
- data/spec/security/certificate_spec.rb +49 -0
- data/spec/security/distinguished_name_spec.rb +46 -0
- data/spec/security/encrypted_document_spec.rb +55 -0
- data/spec/security/rsa_key_pair_spec.rb +55 -0
- data/spec/security/signature_spec.rb +66 -0
- data/spec/security/static_certificate_store_spec.rb +58 -0
- data/spec/sender_spec.rb +1045 -0
- data/spec/serialize/message_pack_spec.rb +131 -0
- data/spec/serialize/secure_serializer_spec.rb +132 -0
- data/spec/serialize/serializable_spec.rb +90 -0
- data/spec/serialize/serializer_spec.rb +197 -0
- data/spec/spec.opts +2 -0
- data/spec/spec.win32.opts +1 -0
- data/spec/spec_helper.rb +130 -0
- data/spec/tracer_spec.rb +114 -0
- metadata +447 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2013 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
24
|
+
|
25
|
+
describe RightScale::ConnectivityChecker do
|
26
|
+
|
27
|
+
include FlexMock::ArgumentTypes
|
28
|
+
|
29
|
+
#describe "and checking connection status" do
|
30
|
+
# before(:each) do
|
31
|
+
# @broker_id = "rs-broker-host-123"
|
32
|
+
# @broker_ids = [@broker_id]
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# it "should not check connection if check already in progress" do
|
36
|
+
# flexmock(EM::Timer).should_receive(:new).and_return(@timer).never
|
37
|
+
# @instance.connectivity_checker.ping_timer = true
|
38
|
+
# flexmock(@instance).should_receive(:publish).never
|
39
|
+
# @instance.connectivity_checker.check(@broker_ids)
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# it "should publish ping to router" do
|
43
|
+
# flexmock(EM::Timer).should_receive(:new).and_return(@timer).once
|
44
|
+
# flexmock(@instance).should_receive(:publish).with(on { |request| request.type.should == "/router/ping" },
|
45
|
+
# @broker_ids).and_return(@broker_ids).once
|
46
|
+
# @instance.connectivity_checker.check(@broker_id)
|
47
|
+
# @instance.pending_requests.size.should == 1
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# it "should not make any connection changes if receive ping response" do
|
51
|
+
# flexmock(RightScale::AgentIdentity).should_receive(:generate).and_return('abc').once
|
52
|
+
# @timer.should_receive(:cancel).once
|
53
|
+
# flexmock(EM::Timer).should_receive(:new).and_return(@timer).once
|
54
|
+
# flexmock(@instance).should_receive(:publish).and_return(@broker_ids).once
|
55
|
+
# @instance.connectivity_checker.check(@broker_id)
|
56
|
+
# @instance.connectivity_checker.ping_timer.should == @timer
|
57
|
+
# @instance.pending_requests.size.should == 1
|
58
|
+
# @instance.pending_requests['abc'].response_handler.call(nil)
|
59
|
+
# @instance.connectivity_checker.ping_timer.should == nil
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# it "should try to reconnect if ping times out repeatedly" do
|
63
|
+
# @log.should_receive(:warning).with(/timed out after 30 seconds/).twice
|
64
|
+
# @log.should_receive(:error).with(/reached maximum of 3 timeouts/).once
|
65
|
+
# flexmock(EM::Timer).should_receive(:new).and_yield.times(3)
|
66
|
+
# flexmock(@agent).should_receive(:connect).once
|
67
|
+
# @instance.connectivity_checker.check(@broker_id)
|
68
|
+
# @instance.connectivity_checker.check(@broker_id)
|
69
|
+
# @instance.connectivity_checker.check(@broker_id)
|
70
|
+
# @instance.connectivity_checker.ping_timer.should == nil
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# it "should log error if attempt to reconnect fails" do
|
74
|
+
# @log.should_receive(:warning).with(/timed out after 30 seconds/).twice
|
75
|
+
# @log.should_receive(:error).with(/Failed to reconnect/, Exception, :trace).once
|
76
|
+
# flexmock(@agent).should_receive(:connect).and_raise(Exception)
|
77
|
+
# flexmock(EM::Timer).should_receive(:new).and_yield.times(3)
|
78
|
+
# @instance.connectivity_checker.check(@broker_id)
|
79
|
+
# @instance.connectivity_checker.check(@broker_id)
|
80
|
+
# @instance.connectivity_checker.check(@broker_id)
|
81
|
+
# end
|
82
|
+
#end
|
83
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_agent', 'core_payload_types'))
|
26
|
+
|
27
|
+
module RightScale
|
28
|
+
describe DevRepositories do
|
29
|
+
before(:each) do
|
30
|
+
@expected_repo1 = { "111" => DevRepository.new(:git, "bunk", nil, nil, nil, nil, nil, "111", [1,2,3]) }
|
31
|
+
@expected_repo2 = { "222" => DevRepository.new(:git, "err", nil, nil, nil, nil, nil, "222", [4,5,6]) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'empty?' do
|
35
|
+
it 'should be empty by default' do
|
36
|
+
DevRepositories.new.empty?.should be_true
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should not be empty when initialized with data' do
|
40
|
+
DevRepositories.new(@expected_repo1).empty?.should be_false
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should should not be empty when a repo is added' do
|
44
|
+
dev_repos = DevRepositories.new
|
45
|
+
dev_repos.add_repo("111", {:repo_type=>:git, :url=>"bunk"}, [1,2,3])
|
46
|
+
dev_repos.empty?.should be_false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'add_repo' do
|
51
|
+
it 'when initially empty, should add without error' do
|
52
|
+
dev_repos = DevRepositories.new
|
53
|
+
dev_repos.add_repo("111", {:repo_type=>:git, :url=>"bunk"}, [1,2,3])
|
54
|
+
dev_repos.serialized_members.first.should == @expected_repo1
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'when initialized with data, should add without error' do
|
58
|
+
dev_repos = DevRepositories.new(@expected_repo1)
|
59
|
+
dev_repos.add_repo("222", {:repo_type=>:git, :url=>"err"}, [4,5,6])
|
60
|
+
dev_repos.serialized_members.first.should == @expected_repo1.merge(@expected_repo2)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_agent', 'core_payload_types'))
|
26
|
+
|
27
|
+
module RightScale
|
28
|
+
describe DevRepository do
|
29
|
+
it 'should serialize 9 parameters' do
|
30
|
+
DevRepository.new.serialized_members.count.should == 9
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_agent', 'core_payload_types'))
|
26
|
+
|
27
|
+
module RightScale
|
28
|
+
describe ExecutableBundle do
|
29
|
+
context 'serialized_members' do
|
30
|
+
it 'contains all serialized elements' do
|
31
|
+
ExecutableBundle.new.serialized_members.count.should == 9
|
32
|
+
end
|
33
|
+
end
|
34
|
+
context 'dev_cookbooks' do
|
35
|
+
context 'when set' do
|
36
|
+
let(:expected_dev_cookbooks) { [{ :foo=>'bar' }] }
|
37
|
+
let(:bundle) { ExecutableBundle.new(nil, nil, nil, nil, nil, nil, expected_dev_cookbooks.clone) }
|
38
|
+
|
39
|
+
it 'should serialize in as the seventh parameter' do
|
40
|
+
bundle.dev_cookbooks.should == expected_dev_cookbooks
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should serialize out as the seventh parameter' do
|
44
|
+
bundle.serialized_members[6].should == expected_dev_cookbooks
|
45
|
+
end
|
46
|
+
end
|
47
|
+
context 'when not set' do
|
48
|
+
let(:bundle) { ExecutableBundle.new }
|
49
|
+
it 'should be nil' do
|
50
|
+
bundle.dev_cookbooks.should be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should serialize to nil" do
|
54
|
+
bundle.serialized_members[6].should be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'runlist policy' do
|
59
|
+
let(:bundle) { ExecutableBundle.new(nil, nil, nil, nil, nil, nil, nil, RunlistPolicy.new) }
|
60
|
+
|
61
|
+
it 'should serialize into a runlist policy object' do
|
62
|
+
bundle.serialized_members[7].should be_an_instance_of(RunlistPolicy)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_agent', 'core_payload_types'))
|
25
|
+
|
26
|
+
# Copy of the old model for RightScale::LoginUser before the public_keys member was added
|
27
|
+
module LoginUserSpec
|
28
|
+
class LoginUserBeforePublicKeys
|
29
|
+
include RightScale::Serializable
|
30
|
+
|
31
|
+
attr_accessor :uuid, :username, :public_key, :common_name, :superuser, :expires_at
|
32
|
+
|
33
|
+
def initialize(*args)
|
34
|
+
@uuid = args[0]
|
35
|
+
@username = args[1]
|
36
|
+
@public_key = args[2]
|
37
|
+
@common_name = args[3] || ''
|
38
|
+
@superuser = args[4] || false
|
39
|
+
@expires_at = Time.at(args[5]) if args[5] && (args[5] != 0)
|
40
|
+
end
|
41
|
+
|
42
|
+
def serialized_members
|
43
|
+
[ @uuid, @username, @public_key, @common_name, @superuser, @expires_at.to_i ]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe RightScale::LoginUser do
|
49
|
+
|
50
|
+
# ensures that the serialization downgrade case works.
|
51
|
+
def test_serialization_downgrade(user, public_key)
|
52
|
+
json = user.to_json
|
53
|
+
old_json = json.gsub("RightScale::LoginUser", "LoginUserSpec::LoginUserBeforePublicKeys")
|
54
|
+
old_user = JSON.parse(old_json)
|
55
|
+
old_user.class.should == LoginUserSpec::LoginUserBeforePublicKeys
|
56
|
+
old_user.public_key.should == public_key
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should serialize old version without public_keys member' do
|
60
|
+
num = rand(2**32).to_s(32)
|
61
|
+
pub = rand(2**32).to_s(32)
|
62
|
+
public_key = "ssh-rsa #{pub} #{num}@rightscale.com"
|
63
|
+
user = LoginUserSpec::LoginUserBeforePublicKeys.new("v0-#{num}", "rs-#{num}", public_key, "#{num}@rightscale.old", true, nil)
|
64
|
+
json = user.to_json
|
65
|
+
json = json.gsub("LoginUserSpec::LoginUserBeforePublicKeys", "RightScale::LoginUser")
|
66
|
+
user = JSON.parse(json)
|
67
|
+
user.public_key.should == public_key
|
68
|
+
user.public_keys.should == [public_key]
|
69
|
+
test_serialization_downgrade(user, public_key)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should serialize current version with single public_key' do
|
73
|
+
num = rand(2**32).to_s(32)
|
74
|
+
pub = rand(2**32).to_s(32)
|
75
|
+
public_key = "ssh-rsa #{pub} #{num}@rightscale.com"
|
76
|
+
user = RightScale::LoginUser.new("v0-#{num}", "rs-#{num}", public_key, "#{num}@rightscale.old", true, nil, nil)
|
77
|
+
json = user.to_json
|
78
|
+
user = JSON.parse(json)
|
79
|
+
user.class.should == RightScale::LoginUser
|
80
|
+
user.public_key.should == public_key
|
81
|
+
user.public_keys.should == [public_key]
|
82
|
+
test_serialization_downgrade(user, public_key)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should serialize current version with multiple public_keys and fingerprints' do
|
86
|
+
num = rand(2**32).to_s(32)
|
87
|
+
public_keys = []
|
88
|
+
fingerprints = []
|
89
|
+
3.times do |i|
|
90
|
+
pub = rand(2**32).to_s(32)
|
91
|
+
public_keys << "ssh-rsa #{pub} #{num}@rightscale.com"
|
92
|
+
fingerprints << "sha#{i}"
|
93
|
+
end
|
94
|
+
new_user = RightScale::LoginUser.new("v0-#{num}", "rs-#{num}", nil, "#{num}@rightscale.old", true, nil, public_keys,
|
95
|
+
nil, fingerprints)
|
96
|
+
new_user.public_key.should == public_keys.first
|
97
|
+
new_user.public_keys.should == public_keys
|
98
|
+
new_user.public_key_fingerprints.should == fingerprints
|
99
|
+
test_serialization_downgrade(new_user, public_keys.first)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#-- -*- mode: ruby; encoding: utf-8 -*-
|
2
|
+
# Copyright: Copyright (c) 2009-2013 RightScale, Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# 'Software'), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_agent', 'core_payload_types'))
|
26
|
+
|
27
|
+
module RightScale
|
28
|
+
describe RecipeInstantiation do
|
29
|
+
let(:nickname) { 'foo' }
|
30
|
+
let(:attributes) do
|
31
|
+
{
|
32
|
+
'rightscale' => {
|
33
|
+
'instance_uuid' => '123-abc',
|
34
|
+
'servers' => {
|
35
|
+
'sketchy' => {
|
36
|
+
'hostname' => 'sketchy123.sketchy.com',
|
37
|
+
'identifier' => '123-abc'
|
38
|
+
},
|
39
|
+
'lumberjack' => {
|
40
|
+
'hostname' => 'syslog123.lumberjack.com',
|
41
|
+
'identifier' => '123-abc'
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
let(:id) { 123 }
|
48
|
+
let(:ready) { true }
|
49
|
+
let(:external_inputs) { {} }
|
50
|
+
let(:input_flags) { {} }
|
51
|
+
|
52
|
+
context 'given all fields' do
|
53
|
+
subject do
|
54
|
+
described_class.new(
|
55
|
+
nickname, attributes, id, ready, external_inputs, input_flags)
|
56
|
+
end
|
57
|
+
|
58
|
+
its(:title) { should == nickname }
|
59
|
+
its(:nickname) { should == nickname }
|
60
|
+
its(:attributes) { should == attributes }
|
61
|
+
its(:id) { should == id }
|
62
|
+
its(:ready) { should == ready }
|
63
|
+
its(:external_inputs) { should == external_inputs }
|
64
|
+
its(:input_flags) { should == input_flags }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'given minimal fields' do
|
68
|
+
subject do
|
69
|
+
described_class.new(nickname, attributes, id, ready)
|
70
|
+
end
|
71
|
+
|
72
|
+
its(:title) { should == nickname }
|
73
|
+
its(:nickname) { should == nickname }
|
74
|
+
its(:attributes) { should == attributes }
|
75
|
+
its(:id) { should == id }
|
76
|
+
its(:ready) { should == ready }
|
77
|
+
its(:external_inputs) { should == nil }
|
78
|
+
its(:input_flags) { should == nil }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#-- -*- mode: ruby; encoding: utf-8 -*-
|
2
|
+
# Copyright: Copyright (c) 2011 RightScale, Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# 'Software'), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_agent', 'core_payload_types'))
|
26
|
+
|
27
|
+
module RightScale
|
28
|
+
describe RightScriptAttachment do
|
29
|
+
context 'as a class' do
|
30
|
+
it 'should compute a simple hash correctly' do
|
31
|
+
RightScriptAttachment.hash_for('http://foo.bar.baz/', 'index.html', 'bsthl').should ==
|
32
|
+
Digest::SHA1.hexdigest("http://foo.bar.baz/\000bsthl")
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should compute a hash with a query term correctly' do
|
36
|
+
RightScriptAttachment.hash_for('http://foo.bar.baz/?q=bar;baz=foo', 'index.html', 'bsthl').should ==
|
37
|
+
Digest::SHA1.hexdigest("http://foo.bar.baz/\000bsthl")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'as an instance' do
|
42
|
+
it 'should compute a simple hash correctly' do
|
43
|
+
RightScriptAttachment.new('http://foo.bar.baz/', 'index.html', 'bsthl').to_hash.should ==
|
44
|
+
Digest::SHA1.hexdigest("http://foo.bar.baz/\000bsthl")
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should compute a hash with a query term correctly' do
|
48
|
+
RightScriptAttachment.new('http://foo.bar.baz/?q=bar;baz=foo', 'index.html', 'bsthl').to_hash.should ==
|
49
|
+
Digest::SHA1.hexdigest("http://foo.bar.baz/\000bsthl")
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should know how to fill out a session' do
|
53
|
+
attachment = RightScriptAttachment.new('http://foo.bar.baz/', 'index.html', 'bsthl')
|
54
|
+
session = flexmock('session')
|
55
|
+
session.should_receive(:[]=).with('scope', 'attachments').once
|
56
|
+
session.should_receive(:[]=).with('resource', attachment.to_hash).once
|
57
|
+
session.should_receive(:[]=).with('url', 'http://foo.bar.baz/').once
|
58
|
+
session.should_receive(:[]=).with('etag', 'bsthl').once
|
59
|
+
session.should_receive(:to_s).and_return("blah").once
|
60
|
+
attachment.fill_out(session)
|
61
|
+
attachment.token.should == "blah"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|