cf-uaa-lib 1.3.8 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/uaa/misc.rb +4 -5
  2. data/lib/uaa/version.rb +1 -1
  3. data/spec/misc_spec.rb +58 -27
  4. metadata +127 -88
data/lib/uaa/misc.rb CHANGED
@@ -68,11 +68,10 @@ class Misc
68
68
  # @return [String] url of UAA (or the target itself if it didn't provide a response)
69
69
  def self.discover_uaa(target)
70
70
  info = server(target)
71
- if info['links'] && info['links']['uaa']
72
- info['links']['uaa']
73
- else
74
- target
75
- end
71
+ links = info['links'] || info[:links]
72
+ uaa = links['uaa'] || links[:uaa]
73
+
74
+ uaa || target
76
75
  end
77
76
 
78
77
  # Gets the key from the server that is used to validate token signatures. If
data/lib/uaa/version.rb CHANGED
@@ -14,6 +14,6 @@
14
14
  # Cloud Foundry namespace
15
15
  module CF
16
16
  module UAA
17
- VERSION = "1.3.8"
17
+ VERSION = "1.3.9"
18
18
  end
19
19
  end
data/spec/misc_spec.rb CHANGED
@@ -16,39 +16,70 @@ require 'uaa/misc'
16
16
 
17
17
  module CF::UAA
18
18
 
19
- describe Misc do
19
+ describe Misc do
20
20
 
21
- include SpecHelper
21
+ include SpecHelper
22
22
 
23
- before :all do
24
- #Util.default_logger(:trace)
25
- end
23
+ before :all do
24
+ #Util.default_logger(:trace)
25
+ end
26
26
 
27
- it "gets server info" do
28
- Misc.set_request_handler do |url, method, body, headers|
29
- url.should == "https://uaa.cloudfoundry.com/login"
30
- method.should == :get
31
- headers["content-type"].should be_nil
32
- headers["accept"].gsub(/\s/, '').should =~ /application\/json;charset=utf-8/i
33
- [200, '{"commit_id":"12345","prompts":["one","two"]}', {"content-type" => "application/json"}]
27
+ before do
28
+ Misc.set_request_handler do |url, method, body, headers|
29
+ url.should == target_url
30
+ method.should == :get
31
+ headers["content-type"].should be_nil
32
+ headers["accept"].gsub(/\s/, '').should =~ /application\/json;charset=utf-8/i
33
+ [200, response_body, {"content-type" => "application/json"}]
34
+ end
34
35
  end
35
- result = Misc.server("https://uaa.cloudfoundry.com")
36
- result["prompts"].should_not be_nil
37
- result["commit_id"].should_not be_nil
38
- end
39
36
 
40
- it "gets UAA target" do
41
- Misc.set_request_handler do |url, method, body, headers|
42
- url.should == "https://login.cloudfoundry.com/login"
43
- method.should == :get
44
- headers["content-type"].should be_nil
45
- headers["accept"].gsub(/\s/, '').should =~ /application\/json;charset=utf-8/i
46
- [200, '{"links":{"uaa":"https://uaa.cloudfoundry.com"},"prompts":["one","two"]}', {"content-type" => "application/json"}]
37
+ describe "getting server info" do
38
+ let(:target_url) { "https://uaa.cloudfoundry.com/login" }
39
+ let(:response_body) { '{"commit_id":"12345","prompts":["one","two"]}' }
40
+
41
+ it "gets server info" do
42
+ result = Misc.server("https://uaa.cloudfoundry.com")
43
+ result["prompts"].should_not be_nil
44
+ result["commit_id"].should_not be_nil
45
+ end
46
+
47
+ context "with symbol keys" do
48
+ around do |example|
49
+ CF::UAA::Misc.symbolize_keys = true
50
+ example.call
51
+ CF::UAA::Misc.symbolize_keys = false
52
+ end
53
+
54
+ it "gets server info" do
55
+ result = Misc.server("https://uaa.cloudfoundry.com")
56
+ result[:prompts].should_not be_nil
57
+ result[:commit_id].should_not be_nil
58
+ end
59
+ end
47
60
  end
48
- result = Misc.discover_uaa("https://login.cloudfoundry.com")
49
- result.should == "https://uaa.cloudfoundry.com"
50
- end
51
61
 
52
- end
62
+ describe "getting UAA target" do
63
+ let(:target_url) { "https://login.cloudfoundry.com/login" }
64
+ let(:response_body) { '{"links":{"uaa":"https://uaa.cloudfoundry.com"},"prompts":["one","two"]}' }
65
+
66
+ it "gets UAA target" do
67
+ result = Misc.discover_uaa("https://login.cloudfoundry.com")
68
+ result.should == "https://uaa.cloudfoundry.com"
69
+ end
53
70
 
71
+ context "with symbol keys" do
72
+ around do |example|
73
+ CF::UAA::Misc.symbolize_keys = true
74
+ example.call
75
+ CF::UAA::Misc.symbolize_keys = false
76
+ end
77
+
78
+ it "gets UAA target" do
79
+ result = Misc.discover_uaa("https://login.cloudfoundry.com")
80
+ result.should == "https://uaa.cloudfoundry.com"
81
+ end
82
+ end
83
+ end
84
+ end
54
85
  end
metadata CHANGED
@@ -1,10 +1,15 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cf-uaa-lib
3
- version: !ruby/object:Gem::Version
4
- version: 1.3.8
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 9
10
+ version: 1.3.9
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Dave Syer
9
14
  - Dale Olds
10
15
  - Joel D'sa
@@ -13,111 +18,135 @@ authors:
13
18
  autorequire:
14
19
  bindir: bin
15
20
  cert_chain: []
16
- date: 2013-03-08 00:00:00.000000000Z
17
- dependencies:
18
- - !ruby/object:Gem::Dependency
21
+
22
+ date: 2013-03-15 00:00:00 Z
23
+ dependencies:
24
+ - !ruby/object:Gem::Dependency
19
25
  name: multi_json
20
- requirement: &21137860 !ruby/object:Gem::Requirement
26
+ prerelease: false
27
+ requirement: &id001 !ruby/object:Gem::Requirement
21
28
  none: false
22
- requirements:
23
- - - ! '>='
24
- - !ruby/object:Gem::Version
25
- version: '0'
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ hash: 3
33
+ segments:
34
+ - 0
35
+ version: "0"
26
36
  type: :runtime
27
- prerelease: false
28
- version_requirements: *21137860
29
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
30
39
  name: bundler
31
- requirement: &21136940 !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
32
42
  none: false
33
- requirements:
34
- - - ! '>='
35
- - !ruby/object:Gem::Version
36
- version: '0'
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
37
50
  type: :development
38
- prerelease: false
39
- version_requirements: *21136940
40
- - !ruby/object:Gem::Dependency
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
41
53
  name: rake
42
- requirement: &21136160 !ruby/object:Gem::Requirement
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
43
56
  none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
48
64
  type: :development
49
- prerelease: false
50
- version_requirements: *21136160
51
- - !ruby/object:Gem::Dependency
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
52
67
  name: rspec
53
- requirement: &21135460 !ruby/object:Gem::Requirement
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
54
70
  none: false
55
- requirements:
56
- - - ! '>='
57
- - !ruby/object:Gem::Version
58
- version: '0'
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
59
78
  type: :development
60
- prerelease: false
61
- version_requirements: *21135460
62
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
63
81
  name: simplecov
64
- requirement: &21134840 !ruby/object:Gem::Requirement
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
65
84
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
70
92
  type: :development
71
- prerelease: false
72
- version_requirements: *21134840
73
- - !ruby/object:Gem::Dependency
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
74
95
  name: simplecov-rcov
75
- requirement: &21134140 !ruby/object:Gem::Requirement
96
+ prerelease: false
97
+ requirement: &id006 !ruby/object:Gem::Requirement
76
98
  none: false
77
- requirements:
78
- - - ! '>='
79
- - !ruby/object:Gem::Version
80
- version: '0'
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
81
106
  type: :development
82
- prerelease: false
83
- version_requirements: *21134140
84
- - !ruby/object:Gem::Dependency
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
85
109
  name: ci_reporter
86
- requirement: &21133500 !ruby/object:Gem::Requirement
110
+ prerelease: false
111
+ requirement: &id007 !ruby/object:Gem::Requirement
87
112
  none: false
88
- requirements:
89
- - - ! '>='
90
- - !ruby/object:Gem::Version
91
- version: '0'
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
92
120
  type: :development
93
- prerelease: false
94
- version_requirements: *21133500
95
- - !ruby/object:Gem::Dependency
121
+ version_requirements: *id007
122
+ - !ruby/object:Gem::Dependency
96
123
  name: json_pure
97
- requirement: &21132540 !ruby/object:Gem::Requirement
124
+ prerelease: false
125
+ requirement: &id008 !ruby/object:Gem::Requirement
98
126
  none: false
99
- requirements:
100
- - - ! '>='
101
- - !ruby/object:Gem::Version
102
- version: '0'
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: 3
131
+ segments:
132
+ - 0
133
+ version: "0"
103
134
  type: :development
104
- prerelease: false
105
- version_requirements: *21132540
106
- description: Client library for interacting with the CloudFoundry User Account and
107
- Authorization (UAA) server. The UAA is an OAuth2 Authorization Server so it can
108
- be used by webapps and command line apps to obtain access tokens to act on behalf
109
- of users. The tokens can then be used to access protected resources in a Resource
110
- Server. This library is for use by UAA client applications or resource servers.
111
- email:
135
+ version_requirements: *id008
136
+ description: Client library for interacting with the CloudFoundry User Account and Authorization (UAA) server. The UAA is an OAuth2 Authorization Server so it can be used by webapps and command line apps to obtain access tokens to act on behalf of users. The tokens can then be used to access protected resources in a Resource Server. This library is for use by UAA client applications or resource servers.
137
+ email:
112
138
  - dsyer@vmware.com
113
139
  - olds@vmware.com
114
140
  - jdsa@vmware.com
115
141
  - vidya@vmware.com
116
142
  - ltaylor@vmware.com
117
143
  executables: []
144
+
118
145
  extensions: []
146
+
119
147
  extra_rdoc_files: []
120
- files:
148
+
149
+ files:
121
150
  - .gitignore
122
151
  - .travis.yml
123
152
  - .yardopts
@@ -144,26 +173,36 @@ files:
144
173
  - spec/token_issuer_spec.rb
145
174
  homepage: https://github.com/cloudfoundry/cf-uaa-lib
146
175
  licenses: []
176
+
147
177
  post_install_message:
148
178
  rdoc_options: []
149
- require_paths:
179
+
180
+ require_paths:
150
181
  - lib
151
- required_ruby_version: !ruby/object:Gem::Requirement
182
+ required_ruby_version: !ruby/object:Gem::Requirement
152
183
  none: false
153
- requirements:
154
- - - ! '>='
155
- - !ruby/object:Gem::Version
156
- version: '0'
157
- required_rubygems_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
190
+ version: "0"
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
192
  none: false
159
- requirements:
160
- - - ! '>='
161
- - !ruby/object:Gem::Version
162
- version: '0'
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ hash: 3
197
+ segments:
198
+ - 0
199
+ version: "0"
163
200
  requirements: []
201
+
164
202
  rubyforge_project: cf-uaa-lib
165
203
  rubygems_version: 1.8.15
166
204
  signing_key:
167
205
  specification_version: 3
168
206
  summary: Client library for CloudFoundry UAA
169
207
  test_files: []
208
+