icontrol 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,79 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe IControl do
4
+ describe "when working offline" do
5
+ it "should be a module" do
6
+ IControl.class.should be(Module)
7
+ end
8
+
9
+ it "should make the module creation on the fly and lazy declared" do
10
+ IControl.const_defined?("MyConst").should be(false)
11
+ IControl::MyConst.class.should be(Module)
12
+ IControl.const_defined?("MyConst").should be(true)
13
+ end
14
+
15
+ it "should create new modules automatically when using :: operator" do
16
+ IControl::NewModule.class.should be(Module)
17
+ end
18
+
19
+ it "should make the class creation on the fly and lazy declared" do
20
+ IControl::NewModule.const_defined?("NewClas").should be(false)
21
+ IControl::NewModule::NewClas.class.should be(Class)
22
+ IControl::NewModule.const_defined?("NewClas").should be(true)
23
+ end
24
+
25
+ it "should create class once it has 2 module ancestors" do
26
+ IControl::NewModule::NewClass.class.should be(Class)
27
+ end
28
+
29
+ it "should have a config variable to be able to configure its behavior and it has to be a Hash" do
30
+ IControl.config.class.should_not be(nil)
31
+ IControl.config.class.should be(Hash)
32
+ end
33
+
34
+ end
35
+
36
+
37
+ describe "when connecting to an endpoint" do
38
+
39
+ describe "and not yet configured" do
40
+ it "should raise an exception if a method is called" do
41
+ IControl.config[:user] = ""
42
+ lambda{
43
+ IControl::GlobalLB::Rule.get_list
44
+ }.should raise_exception IControl::NotConfiguredException
45
+ end
46
+ end
47
+
48
+
49
+ describe "and already configured" do
50
+ before do
51
+ IControl.config[:base_url] = "https://localhost/iControl/iControlPortal.cgi"
52
+ IControl.config[:user] = "test_user"
53
+ IControl.config[:password] = "secret"
54
+
55
+ FakeWeb.register_uri :get, EndpointHelper.wsdl_endpoint("IControl::GlobalLB::Rule"), :body => WSDLFixture.wsdl("IControl.GlobalLB.Rule")
56
+ FakeWeb.register_uri :post, EndpointHelper.soap_endpoint, :body => WSDLFixture.wsdl("IControl.GlobalLB.Rule")
57
+ end
58
+
59
+ after do
60
+ FakeWeb.clean_registry
61
+ IControl.config[:base_url] = IControl.config[:user] = IControl.config[:password] = ""
62
+ end
63
+
64
+ it "should create a class and read its wsdl on the fly thus declaring its operations" do
65
+ IControl::GlobalLB::Rule.wsdl.should_not be(nil)
66
+ IControl::GlobalLB::Rule.wsdl.operations.should_not be(nil)
67
+ end
68
+
69
+ it "should allow the pass of a block when calling server methods" do
70
+ lambda{
71
+ IControl::GlobalLB::Rule.get_list do |soap|
72
+ raise "this should be happening"
73
+ end
74
+ }.should raise_exception
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,54 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'icontrol'
4
+ require "rake"
5
+ require 'spec'
6
+ require 'spec/autorun'
7
+ require 'fakeweb'
8
+ require 'ap'
9
+ Savon::Request.log = false
10
+ FakeWeb.allow_net_connect = false
11
+
12
+ FileList["spec/fixtures/**/*.rb"].each { |fixture| require fixture }
13
+
14
+
15
+ def register_conversation(conversation)
16
+ response_file_names = []
17
+ file_name = ""
18
+ conversation.each do |op|
19
+ file_name = FileList["spec/fixtures/soap/xml/*#{op}_*request*"].first
20
+ response_file_names << file_name.gsub("request","response")
21
+ end
22
+
23
+
24
+ FakeWeb.register_uri :post, EndpointHelper.soap_endpoint, File.read(file_name), response_file_names.map{ |i| {:body => File.read(i)}}
25
+
26
+ end
27
+
28
+ # Mapping of the wsdl's
29
+ def register_wsdls
30
+ puts "Registering wsdls"
31
+ FileList["spec/fixtures/wsdl/xml/*"].each do |file_name|
32
+ klass = file_name.split("/").last.gsub(".xml","").to_s.gsub(".","::").to_s
33
+ FakeWeb.register_uri :get, EndpointHelper.wsdl_endpoint(klass), :body => File.read(file_name)
34
+ end
35
+ end
36
+
37
+ # Mapping of the soap conversations
38
+ def register_fixtures
39
+ FileList["spec/fixtures/soap/xml/*request*"].each do |file_name|
40
+ response_file_name = file_name.gsub("request","response")
41
+ request_body = File.read(file_name)
42
+ FakeWeb.register_uri :post, EndpointHelper.soap_endpoint, File.read(file_name), :body => File.read(response_file_name)
43
+ end
44
+ end
45
+
46
+ Spec::Runner.configure do |config|
47
+ IControl.config[:base_url] = "https://localhost:443/iControl/iControlPortal.cgi"
48
+ IControl.config[:user] = "test_user"
49
+ IControl.config[:password] = "secret"
50
+
51
+ register_wsdls
52
+ register_fixtures
53
+ # FakeWeb::Registry.instance.uri_map.each {|k,v| ap k; v.each {|i,j| ap j.keys }}
54
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icontrol
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Jose Fernandez (magec)
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-23 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: fakeweb
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 1
48
+ - 2
49
+ - 8
50
+ version: 1.2.8
51
+ type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: savon
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :runtime
66
+ version_requirements: *id003
67
+ description: This gem allows you to Connect to a F5 appliance by means of its web services
68
+ email: jfernandezperez@gmail.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files:
74
+ - LICENSE
75
+ - README.markdown
76
+ - README.rdoc
77
+ files:
78
+ - lib/icontrol.rb
79
+ - lib/icontrol/attributable.rb
80
+ - lib/icontrol/base.rb
81
+ - lib/icontrol/common.rb
82
+ - lib/icontrol/local_lb/common.rb
83
+ - lib/icontrol/local_lb/monitor.rb
84
+ - lib/icontrol/local_lb/monitor_rule.rb
85
+ - lib/icontrol/local_lb/pool.rb
86
+ - lib/icontrol/local_lb/pool_member.rb
87
+ - lib/icontrol/local_lb/profile_auth.rb
88
+ - lib/icontrol/local_lb/profile_http_class.rb
89
+ - lib/icontrol/local_lb/rate_class.rb
90
+ - lib/icontrol/local_lb/rule.rb
91
+ - lib/icontrol/local_lb/snat_pool.rb
92
+ - lib/icontrol/local_lb/virtual_server.rb
93
+ - lib/icontrol/mappings.rb
94
+ - lib/icontrol/statistic_type.rb
95
+ - LICENSE
96
+ - README.markdown
97
+ - README.rdoc
98
+ - spec/icontrol_local_lb_pool_spec.rb
99
+ - spec/icontrol_local_lb_profile_http_class_spec.rb
100
+ - spec/icontrol_local_lb_virtual_server_spec.rb
101
+ - spec/fixtures/soap/soap_fixture.rb
102
+ - spec/fixtures/wsdl/wsdl_fixture.rb
103
+ - spec/fixtures/endpoint_helper.rb
104
+ - spec/spec_helper.rb
105
+ - spec/icontrol_local_lb_rule_spec.rb
106
+ - spec/icontrol_spec.rb
107
+ has_rdoc: true
108
+ homepage: http://github.com/magec/icontrol
109
+ licenses: []
110
+
111
+ post_install_message:
112
+ rdoc_options:
113
+ - --charset=UTF-8
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: 3
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ requirements: []
135
+
136
+ rubyforge_project:
137
+ rubygems_version: 1.3.7
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: A ruby client to the BigIP F5
141
+ test_files:
142
+ - spec/icontrol_local_lb_pool_spec.rb
143
+ - spec/icontrol_local_lb_profile_http_class_spec.rb
144
+ - spec/icontrol_local_lb_virtual_server_spec.rb
145
+ - spec/fixtures/soap/soap_fixture.rb
146
+ - spec/fixtures/wsdl/wsdl_fixture.rb
147
+ - spec/fixtures/endpoint_helper.rb
148
+ - spec/spec_helper.rb
149
+ - spec/icontrol_local_lb_rule_spec.rb
150
+ - spec/icontrol_spec.rb