openshift-origin-controller 1.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of openshift-origin-controller might be problematic. Click here for more details.

Files changed (180) hide show
  1. data/COPYRIGHT +1 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +12 -0
  4. data/README.md +3 -0
  5. data/Rakefile +9 -0
  6. data/app/controllers/app_events_controller.rb +115 -0
  7. data/app/controllers/application_templates_controller.rb +19 -0
  8. data/app/controllers/applications_controller.rb +214 -0
  9. data/app/controllers/base_controller.rb +367 -0
  10. data/app/controllers/cartridges_controller.rb +48 -0
  11. data/app/controllers/descriptors_controller.rb +23 -0
  12. data/app/controllers/dns_resolvable_controller.rb +35 -0
  13. data/app/controllers/domains_controller.rb +156 -0
  14. data/app/controllers/emb_cart_controller.rb +276 -0
  15. data/app/controllers/emb_cart_events_controller.rb +52 -0
  16. data/app/controllers/environment_controller.rb +11 -0
  17. data/app/controllers/estimates_controller.rb +71 -0
  18. data/app/controllers/gear_groups_controller.rb +53 -0
  19. data/app/controllers/gears_controller.rb +70 -0
  20. data/app/controllers/keys_controller.rb +96 -0
  21. data/app/controllers/legacy_broker_controller.rb +510 -0
  22. data/app/controllers/quickstarts_controller.rb +29 -0
  23. data/app/controllers/user_controller.rb +38 -0
  24. data/app/helpers/cartridge_helper.rb +25 -0
  25. data/app/helpers/legacy_broker_helper.rb +21 -0
  26. data/app/helpers/user_action_logger.rb +38 -0
  27. data/app/models/application.rb +1718 -0
  28. data/app/models/application_template.rb +27 -0
  29. data/app/models/cartridge_cache.rb +51 -0
  30. data/app/models/cloud_user.rb +334 -0
  31. data/app/models/component_instance.rb +228 -0
  32. data/app/models/connection_endpoint.rb +10 -0
  33. data/app/models/district.rb +210 -0
  34. data/app/models/domain.rb +234 -0
  35. data/app/models/gear.rb +376 -0
  36. data/app/models/group_instance.rb +306 -0
  37. data/app/models/key.rb +20 -0
  38. data/app/models/legacy_reply.rb +15 -0
  39. data/app/models/legacy_request.rb +126 -0
  40. data/app/models/link.rb +11 -0
  41. data/app/models/message.rb +10 -0
  42. data/app/models/name_server_cache.rb +46 -0
  43. data/app/models/optional_param.rb +12 -0
  44. data/app/models/param.rb +13 -0
  45. data/app/models/remote_job.rb +57 -0
  46. data/app/models/rest_application.rb +126 -0
  47. data/app/models/rest_application10.rb +106 -0
  48. data/app/models/rest_application12.rb +124 -0
  49. data/app/models/rest_application_estimate.rb +12 -0
  50. data/app/models/rest_application_template.rb +20 -0
  51. data/app/models/rest_cartridge10.rb +41 -0
  52. data/app/models/rest_cartridge11.rb +151 -0
  53. data/app/models/rest_domain.rb +43 -0
  54. data/app/models/rest_domain10.rb +42 -0
  55. data/app/models/rest_estimates.rb +16 -0
  56. data/app/models/rest_gear.rb +14 -0
  57. data/app/models/rest_gear_group.rb +26 -0
  58. data/app/models/rest_key.rb +24 -0
  59. data/app/models/rest_reply.rb +31 -0
  60. data/app/models/rest_user.rb +43 -0
  61. data/app/models/result_io.rb +67 -0
  62. data/app/models/usage_record.rb +37 -0
  63. data/app/models/validators/app_validator.rb +30 -0
  64. data/app/models/validators/key_validator.rb +30 -0
  65. data/app/models/validators/namespace_validator.rb +18 -0
  66. data/config/routes.rb +36 -0
  67. data/lib/controller_engine.rb +7 -0
  68. data/lib/openshift-origin-controller.rb +14 -0
  69. data/lib/openshift/application_container_proxy.rb +241 -0
  70. data/lib/openshift/auth_service.rb +101 -0
  71. data/lib/openshift/data_store.rb +33 -0
  72. data/lib/openshift/dns_service.rb +41 -0
  73. data/lib/openshift/mongo_data_store.rb +671 -0
  74. data/openshift-origin-controller.gemspec +42 -0
  75. data/rubygem-openshift-origin-controller.spec +274 -0
  76. data/test/cucumber/application-estimate.feature +25 -0
  77. data/test/cucumber/cartridge-10gen-mms-agent.feature +28 -0
  78. data/test/cucumber/cartridge-cron.feature +32 -0
  79. data/test/cucumber/cartridge-haproxy.feature +31 -0
  80. data/test/cucumber/cartridge-jenkins-build.feature +12 -0
  81. data/test/cucumber/cartridge-jenkins-client.feature +10 -0
  82. data/test/cucumber/cartridge-lifecycle-diy.feature +21 -0
  83. data/test/cucumber/cartridge-lifecycle-jbossas.feature +61 -0
  84. data/test/cucumber/cartridge-lifecycle-jbosseap.feature +61 -0
  85. data/test/cucumber/cartridge-lifecycle-jbossews10.feature +61 -0
  86. data/test/cucumber/cartridge-lifecycle-jenkins.feature +41 -0
  87. data/test/cucumber/cartridge-lifecycle-nodejs.feature +59 -0
  88. data/test/cucumber/cartridge-lifecycle-perl.feature +40 -0
  89. data/test/cucumber/cartridge-lifecycle-php.feature +106 -0
  90. data/test/cucumber/cartridge-lifecycle-python.feature +40 -0
  91. data/test/cucumber/cartridge-lifecycle-ruby18.feature +49 -0
  92. data/test/cucumber/cartridge-lifecycle-ruby19.feature +41 -0
  93. data/test/cucumber/cartridge-mongodb.feature +31 -0
  94. data/test/cucumber/cartridge-mysql.feature +30 -0
  95. data/test/cucumber/cartridge-php.feature +14 -0
  96. data/test/cucumber/cartridge-phpmyadmin.feature +32 -0
  97. data/test/cucumber/cartridge-postgresql.feature +32 -0
  98. data/test/cucumber/cartridge-runtime-extended-db.feature +64 -0
  99. data/test/cucumber/cartridge-runtime-extended-jboss.feature +24 -0
  100. data/test/cucumber/cartridge-runtime-extended-nodejs.feature +21 -0
  101. data/test/cucumber/cartridge-runtime-extended-perl.feature +18 -0
  102. data/test/cucumber/cartridge-runtime-extended-php.feature +19 -0
  103. data/test/cucumber/cartridge-runtime-extended-python.feature +18 -0
  104. data/test/cucumber/cartridge-runtime-extended-ruby.feature +22 -0
  105. data/test/cucumber/cartridge-runtime-standard-diy.feature +6 -0
  106. data/test/cucumber/cartridge-runtime-standard-jbossas.feature +7 -0
  107. data/test/cucumber/cartridge-runtime-standard-jbosseap.feature +7 -0
  108. data/test/cucumber/cartridge-runtime-standard-jbossews10.feature +7 -0
  109. data/test/cucumber/cartridge-runtime-standard-jenkins.feature +8 -0
  110. data/test/cucumber/cartridge-runtime-standard-nodejs.feature +7 -0
  111. data/test/cucumber/cartridge-runtime-standard-perl.feature +6 -0
  112. data/test/cucumber/cartridge-runtime-standard-php.feature +6 -0
  113. data/test/cucumber/cartridge-runtime-standard-python.feature +6 -0
  114. data/test/cucumber/cartridge-runtime-standard-ruby.feature +19 -0
  115. data/test/cucumber/cartridge-switchyard.feature +36 -0
  116. data/test/cucumber/descriptor.feature +40 -0
  117. data/test/cucumber/embedded.feature +44 -0
  118. data/test/cucumber/idler.feature +75 -0
  119. data/test/cucumber/misc/descriptor/manifest.yml +22 -0
  120. data/test/cucumber/misc/php/db_test.php +21 -0
  121. data/test/cucumber/openshift-node.feature +21 -0
  122. data/test/cucumber/rest-application-templates.feature +31 -0
  123. data/test/cucumber/rest-applications.feature +431 -0
  124. data/test/cucumber/rest-cartridge-types.feature +16 -0
  125. data/test/cucumber/rest-domains.feature +276 -0
  126. data/test/cucumber/rest-gears.feature +38 -0
  127. data/test/cucumber/rest-keys.feature +247 -0
  128. data/test/cucumber/rest-quickstarts.feature +27 -0
  129. data/test/cucumber/rest-workflow.feature +64 -0
  130. data/test/cucumber/step_definitions/api_steps.rb +369 -0
  131. data/test/cucumber/step_definitions/application-estimate-steps.rb +51 -0
  132. data/test/cucumber/step_definitions/application_steps.rb +215 -0
  133. data/test/cucumber/step_definitions/cartridge-10gen-mms-agent_steps.rb +11 -0
  134. data/test/cucumber/step_definitions/cartridge-cron_steps.rb +51 -0
  135. data/test/cucumber/step_definitions/cartridge-haproxy_steps.rb +30 -0
  136. data/test/cucumber/step_definitions/cartridge-jenkins_steps.rb +93 -0
  137. data/test/cucumber/step_definitions/cartridge-lifecycle-nodejs_steps.rb +30 -0
  138. data/test/cucumber/step_definitions/cartridge-mongodb_steps.rb +60 -0
  139. data/test/cucumber/step_definitions/cartridge-mysql_steps.rb +56 -0
  140. data/test/cucumber/step_definitions/cartridge-php_steps.rb +72 -0
  141. data/test/cucumber/step_definitions/cartridge-postgresql_steps.rb +59 -0
  142. data/test/cucumber/step_definitions/cartridge-switchyard_steps.rb +29 -0
  143. data/test/cucumber/step_definitions/client_steps.rb +12 -0
  144. data/test/cucumber/step_definitions/descriptor_step.rb +32 -0
  145. data/test/cucumber/step_definitions/idler_steps.rb +37 -0
  146. data/test/cucumber/step_definitions/node_steps.rb +203 -0
  147. data/test/cucumber/step_definitions/runtime_steps.rb +547 -0
  148. data/test/cucumber/step_definitions/runtime_url_steps.rb +46 -0
  149. data/test/cucumber/step_definitions/trap-user-extended_steps.rb +14 -0
  150. data/test/cucumber/step_definitions/trap-user_steps.rb +58 -0
  151. data/test/cucumber/support/00_setup_helper.rb +106 -0
  152. data/test/cucumber/support/app_helper.rb +243 -0
  153. data/test/cucumber/support/assertions.rb +52 -0
  154. data/test/cucumber/support/command_helper.rb +453 -0
  155. data/test/cucumber/support/dns_helper.rb +54 -0
  156. data/test/cucumber/support/env.rb +5 -0
  157. data/test/cucumber/support/process_helper.rb +44 -0
  158. data/test/cucumber/support/runtime_support.rb +440 -0
  159. data/test/cucumber/support/unused.rb +27 -0
  160. data/test/cucumber/support/user_helper.rb +37 -0
  161. data/test/cucumber/trap-user-extended.feature +53 -0
  162. data/test/cucumber/trap-user.feature +34 -0
  163. data/test/ddns/1.168.192-rev.db.init +13 -0
  164. data/test/ddns/HOWTO.txt +207 -0
  165. data/test/ddns/Kexample.com.+157+06142.key +1 -0
  166. data/test/ddns/Kexample.com.+157+06142.private +7 -0
  167. data/test/ddns/authconfig.rb +14 -0
  168. data/test/ddns/example.com.db.init +23 -0
  169. data/test/ddns/example.com.key +4 -0
  170. data/test/ddns/named.ca +52 -0
  171. data/test/ddns/named.conf +48 -0
  172. data/test/ddns/named.empty +10 -0
  173. data/test/ddns/named.localhost +10 -0
  174. data/test/ddns/named.loopback +11 -0
  175. data/test/ddns/named.rfc1912.zones +42 -0
  176. data/test/ddns/named.root.key +5 -0
  177. data/test/ddns/named_service.rb +127 -0
  178. data/test/unit/bind_dns_service_test.rb +167 -0
  179. data/test/unit/broker_auth_test.rb +28 -0
  180. metadata +545 -0
@@ -0,0 +1,48 @@
1
+ // named.conf
2
+
3
+ options {
4
+ listen-on port 10053 { 127.0.0.1; };
5
+ directory ".";
6
+ allow-query { localhost; };
7
+ recursion no;
8
+
9
+ pid-file "tmp/named.pid";
10
+ session-keyfile "tmp/named.session.key";
11
+ managed-keys-directory "tmp";
12
+ };
13
+
14
+ // disable remote controls
15
+ controls {};
16
+
17
+ logging {
18
+ channel default_debug {
19
+ //file "data/named.run";
20
+ file "tmp/named.log";
21
+ severity dynamic;
22
+ };
23
+ };
24
+
25
+ zone "." IN {
26
+ type hint;
27
+ file "named.ca";
28
+ };
29
+
30
+ include "named.rfc1912.zones";
31
+
32
+ //
33
+ // Local customization
34
+ //
35
+
36
+ include "example.com.key";
37
+
38
+ zone "example.com" IN {
39
+ type master;
40
+ file "tmp/example.com.db";
41
+ allow-update { key example.com ; };
42
+ };
43
+
44
+ zone "1.168.192.in-addr.arpa" {
45
+ type master;
46
+ file "tmp/1.168.192-rev.db";
47
+ allow-update { key example.com ; } ;
48
+ };
@@ -0,0 +1,10 @@
1
+ $TTL 3H
2
+ @ IN SOA @ rname.invalid. (
3
+ 0 ; serial
4
+ 1D ; refresh
5
+ 1H ; retry
6
+ 1W ; expire
7
+ 3H ) ; minimum
8
+ NS @
9
+ A 127.0.0.1
10
+ ;; AAAA ::1
@@ -0,0 +1,10 @@
1
+ $TTL 1D
2
+ @ IN SOA @ rname.invalid. (
3
+ 0 ; serial
4
+ 1D ; refresh
5
+ 1H ; retry
6
+ 1W ; expire
7
+ 3H ) ; minimum
8
+ NS @
9
+ A 127.0.0.1
10
+ ;; AAAA ::1
@@ -0,0 +1,11 @@
1
+ $TTL 1D
2
+ @ IN SOA @ rname.invalid. (
3
+ 0 ; serial
4
+ 1D ; refresh
5
+ 1H ; retry
6
+ 1W ; expire
7
+ 3H ) ; minimum
8
+ NS @
9
+ A 127.0.0.1
10
+ ;; AAAA ::1
11
+ PTR localhost.
@@ -0,0 +1,42 @@
1
+ // named.rfc1912.zones:
2
+ //
3
+ // Provided by Red Hat caching-nameserver package
4
+ //
5
+ // ISC BIND named zone configuration for zones recommended by
6
+ // RFC 1912 section 4.1 : localhost TLDs and address zones
7
+ // and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
8
+ // (c)2007 R W Franks
9
+ //
10
+ // See /usr/share/doc/bind*/sample/ for example named configuration files.
11
+ //
12
+
13
+ zone "localhost.localdomain" IN {
14
+ type master;
15
+ file "named.localhost";
16
+ allow-update { none; };
17
+ };
18
+
19
+ zone "localhost" IN {
20
+ type master;
21
+ file "named.localhost";
22
+ allow-update { none; };
23
+ };
24
+
25
+ zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
26
+ type master;
27
+ file "named.loopback";
28
+ allow-update { none; };
29
+ };
30
+
31
+ zone "1.0.0.127.in-addr.arpa" IN {
32
+ type master;
33
+ file "named.loopback";
34
+ allow-update { none; };
35
+ };
36
+
37
+ zone "0.in-addr.arpa" IN {
38
+ type master;
39
+ file "named.empty";
40
+ allow-update { none; };
41
+ };
42
+
@@ -0,0 +1,5 @@
1
+ managed-keys {
2
+ # DNSKEY for the root zone.
3
+ # Updates are published on root-dnssec-announce@icann.org
4
+ . initial-key 257 3 8 "AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjF FVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoX bfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaD X6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpz W5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relS Qageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulq QxA+Uk1ihz0=";
5
+ };
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #
3
+ # Control a BIND DNS service for testing
4
+ #
5
+
6
+
7
+ require 'rubygems'
8
+ require 'open4'
9
+ require 'ftools' # adds File.cp
10
+ require 'fileutils' # for change directory
11
+
12
+ require 'dnsruby'
13
+
14
+ named_dir = File.dirname(__FILE__)
15
+
16
+ class BindTestService
17
+
18
+ attr_reader :testroot, :pid
19
+ def initialize(testroot=named_dir)
20
+
21
+ @testroot = testroot
22
+
23
+ # get server, port, keyname, keyvalue, zone, domain_suffix
24
+ reset
25
+ end
26
+
27
+ def clean
28
+ begin
29
+ cwd = FileUtils.pwd
30
+ FileUtils.cd @testroot
31
+
32
+ # delete all journal files
33
+ `rm -f tmp/*.jnl`
34
+
35
+ # delete the dynamic managed keys file
36
+ if File.exists? 'tmp/managed-keys.bind'
37
+ File.delete 'tmp/managed-keys.bind'
38
+ end
39
+
40
+ ensure
41
+ FileUtils.cd cwd
42
+ end
43
+ end
44
+
45
+ def reset
46
+ clean
47
+ begin
48
+ cwd = FileUtils.pwd
49
+ FileUtils.cd @testroot
50
+
51
+ # copy the initial example.db in place
52
+ File.copy("example.com.db.init", "tmp/example.com.db")
53
+ File.copy("1.168.192-rev.db.init", "tmp/1.168.192-rev.db")
54
+
55
+ ensure
56
+ FileUtils.cd cwd
57
+ end
58
+ end
59
+
60
+ # start the daemon
61
+ def start
62
+
63
+ if @pid != nil
64
+ raise "I think a named is already running with PID #{@pid}"
65
+ end
66
+
67
+ begin
68
+ cwd = FileUtils.pwd
69
+ FileUtils.cd @testroot
70
+
71
+ begin
72
+ pid, stdin, stdout, stderr = Open4::popen4 "/usr/sbin/named -c named.conf"
73
+
74
+ # Need to check if there already is one
75
+
76
+ stdin.close
77
+ stdout.close
78
+ stderr.close
79
+
80
+ sleep 2
81
+ @pid = File.open("tmp/named.pid").read.to_i
82
+ ensure
83
+ FileUtils.cd cwd
84
+ end
85
+ end
86
+ end
87
+
88
+ def stop
89
+ if @pid == nil
90
+ raise "no PID: is there really a named running?"
91
+ end
92
+
93
+ Process.kill('INT', @pid)
94
+ @pid = nil
95
+ end
96
+
97
+ def self.stop(named_root)
98
+ pid = File.read("#{named_root}/tmp/named.pid").strip.to_i
99
+ Process.kill('INT', pid)
100
+ end
101
+
102
+ def self.clean(named_root)
103
+ FileUtils.cd named_root
104
+ `rm -f tmp/*`
105
+ end
106
+ end
107
+
108
+ if __FILE__ == $0
109
+ # UPDATE AS NEEDED
110
+
111
+ case ARGV[0]
112
+ when "start"
113
+ c = BindTestService.new named_dir
114
+
115
+ c.reset
116
+ c.start
117
+
118
+ when "stop"
119
+ BindTestService.stop named_dir
120
+
121
+ when "clean"
122
+ BindTestService.clean named_dir
123
+ else
124
+
125
+ end
126
+ end
127
+
@@ -0,0 +1,167 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+ require 'active_support'
5
+ require 'test/unit'
6
+ require 'mocha'
7
+
8
+ require 'ddns/named_service'
9
+
10
+ require 'dnsruby'
11
+ require 'lib/openshift-origin-controller/lib/openshift/dns_service'
12
+ require 'lib/openshift-origin-controller/lib/openshift/bind_dns_service'
13
+
14
+
15
+ class BindDnsServiceTest < ActiveSupport::TestCase
16
+ include OpenShift
17
+
18
+ # this is here so I can comment tests out
19
+ def self.notest(t)
20
+
21
+ end
22
+
23
+ def setup
24
+ super
25
+ @dns_root = File.dirname(File.dirname(__FILE__)) + "/ddns"
26
+
27
+ load "#{@dns_root}/authconfig.rb" if not defined? $config
28
+ @config = {
29
+ :server => '127.0.0.1',
30
+ :port => 10053,
31
+ :keyname => 'example.com',
32
+ :keyvalue => 'H6NDDnTbNpcBrUM5c4BJtohyK2uuZ5Oi6jxg3ME+RJsNl5Wl2B87oL12YxWUR3Gp7FdZQojTKBSfs5ZjghYxGw==',
33
+ :zone => "example.com",
34
+ :domain_suffix => "example.com"
35
+ }
36
+
37
+ @named = BindTestService.new @dns_root
38
+ @named.start
39
+ sleep 2
40
+
41
+ #begin
42
+ # puts "Checking presence of config information"
43
+ # puts "Rails.application.config = #{Rails.application.config}"
44
+ #rescue
45
+ # puts "Rails config is not present"
46
+ #end
47
+
48
+ @resolver = Dnsruby::Resolver.new(:nameserver => @config[:server],
49
+ :port => @config[:port])
50
+ end
51
+
52
+ #
53
+ test "namespace is registered?" do
54
+ # verify that the namespace is not registered
55
+ client = BindDnsService.new @config
56
+ assert(client.server, "127.0.0.1")
57
+ assert(client.namespace_available?('missing'), 'namespace reported in use when available')
58
+ assert(!client.namespace_available?('testns1'), 'namespace reported available when in use')
59
+ end
60
+
61
+ test "register a namespace" do
62
+ client = BindDnsService.new @config
63
+
64
+ testns = "testns2"
65
+ #assert(client.server, "127.0.0.1")
66
+ #assert(client.namespace_available?(namespace))
67
+
68
+ client.register_namespace(testns)
69
+
70
+ fqdn = "#{testns}.#{@config[:domain_suffix]}"
71
+
72
+ result = nil
73
+ assert_nothing_raised do
74
+ # request
75
+ result = @resolver.query(fqdn, Dnsruby::Types::TXT)
76
+ end
77
+
78
+ # check for success: result is Dnsruby::Message
79
+ assert_instance_of(Dnsruby::Message, result)
80
+
81
+ # result.answer.count = 1
82
+ assert_equal(1, result.answer.count, "expected 1 result, got #{result.answer.count}")
83
+
84
+ # result.answer[0].name.to_s = fqdn
85
+ assert_equal(fqdn, result.answer[0].name.to_s, "expected FQDN #{fqdn}")
86
+
87
+ end
88
+
89
+ test "deregister a namespace" do
90
+ client = BindDnsService.new @config
91
+
92
+ testns = "testns1"
93
+ fqdn = "#{testns}.#{@config[:domain_suffix]}"
94
+
95
+ #assert(client.server, "127.0.0.1")
96
+ #assert(client.namespace_available?(namespace))
97
+
98
+ client.deregister_namespace(testns)
99
+
100
+ result = nil
101
+ assert_raise Dnsruby::NXDomain do
102
+ # request
103
+ result = @resolver.query(fqdn, Dnsruby::Types::TXT)
104
+ end
105
+
106
+ end
107
+
108
+ test "register an application" do
109
+ client = BindDnsService.new @config
110
+
111
+ testns = "testns3"
112
+ testapp = "testapp3"
113
+ fqdn = "#{testapp}-#{testns}.#{@config[:domain_suffix]}"
114
+ nodename = "node.#{@config[:domain_suffix]}"
115
+
116
+ # add the app
117
+ client.register_application(testapp, testns, nodename)
118
+
119
+ # now check that it's there
120
+ result = nil
121
+ assert_nothing_raised do
122
+ # request
123
+ result = @resolver.query(fqdn, 'CNAME')
124
+ end
125
+
126
+ # check for success: result is Dnsruby::Message
127
+ assert_instance_of(Dnsruby::Message, result)
128
+
129
+ # result.answer.count = 1
130
+ assert_equal(1, result.answer.count, "expected 1 result, got #{result.answer.count}")
131
+
132
+ # result.answer[0].name.to_s = fqdn
133
+ assert_equal(nodename, result.answer[0].rdata.to_s, "expected FQDN #{nodename}")
134
+
135
+ end
136
+
137
+ test "deregister an application" do
138
+ client = BindDnsService.new @config
139
+
140
+ testns = "testns4"
141
+ testapp = "testapp4"
142
+ fqdn = "#{testapp}-#{testns}.#{@config[:domain_suffix]}"
143
+ nodename = "node.#{@config[:domain_suffix]}"
144
+
145
+ # add the app
146
+ client.deregister_application(testapp, testns)
147
+ sleep 2
148
+
149
+ lookup = Dnsruby::Resolver.new(
150
+ :nameserver => @config[:server],
151
+ :port => @config[:port])
152
+
153
+ result = nil
154
+ assert_raise Dnsruby::NXDomain do
155
+ # request
156
+ #result = resolver.query(fqdn, 'CNAME')
157
+ result = lookup.query(fqdn, 'CNAME')
158
+ end
159
+ end
160
+
161
+ def teardown
162
+ super
163
+ @named.stop
164
+ @named.clean
165
+ end
166
+
167
+ end
@@ -0,0 +1,28 @@
1
+ require 'test/unit'
2
+ require 'test_helper'
3
+
4
+ class BrokerAuthTest < Test::Unit::TestCase
5
+ def setup
6
+ test_key_dir = "#{File.dirname(__FILE__)}/../dummy/config/"
7
+ system "/usr/bin/openssl genrsa -out #{test_key_dir}/server_priv.pem 2048"
8
+ system "/usr/bin/openssl rsa -in #{test_key_dir}/server_priv.pem -pubout > #{test_key_dir}/server_pub.pem"
9
+ @auth_service = OpenShift::MongoAuthService.new
10
+ end
11
+
12
+ def test_broker_auth
13
+ app = Mocha::Mock.new
14
+ user = Mocha::Mock.new
15
+ t = Time.new
16
+
17
+ user.expects(:login).returns("foo@example.com")
18
+ app.expects(:name).at_least_once.returns("foo")
19
+ app.expects(:user).returns(user)
20
+ app.expects(:creation_time).at_least_once.returns(t)
21
+
22
+ CloudUser.expects(:find).at_least_once.returns(user)
23
+ user.expects(:applications).at_least_once.returns([app])
24
+
25
+ iv,token = @auth_service.generate_broker_key(app)
26
+ @auth_service.validate_broker_key(iv,token)
27
+ end
28
+ end