File: openid_spec.rb

package info (click to toggle)
tdiary-contrib 5.0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,660 kB
  • sloc: ruby: 17,024; lisp: 546; xml: 451; php: 61; sql: 40; makefile: 18
file content (246 lines) | stat: -rw-r--r-- 7,034 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
$:.unshift(File.dirname(__FILE__))
require 'spec_helper'

describe "openid plugin w/" do
	def setup_open_id_plugin(service, userid)
		fake_plugin(:openid) { |plugin|
			plugin.mode = 'latest'
			plugin.conf['openid.service'] = service
			plugin.conf['openid.id'] = userid
		}
	end

	describe "Hatena" do
		before do
			plugin = setup_open_id_plugin('Hatena', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.server',
				:href => 'https://www.hatena.ne.jp/openid/server')}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.delegate',
				:href => 'http://www.hatena.ne.jp/tdtds/')}
	end

	describe "livedoor" do
		before do
			plugin = setup_open_id_plugin('livedoor', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.server',
				:href => 'http://auth.livedoor.com/openid/server')}

		it { expect(@header_snippet).to include_link_tag_with(
			:rel => 'openid.delegate',
			:href => 'http://profile.livedoor.com/tdtds')}
	end

	describe "LiveJournal" do
		before do
			plugin = setup_open_id_plugin('LiveJournal', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.server',
				:href => 'http://www.livejournal.com/openid/server.bml')}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.delegate',
				:href => 'http://tdtds.livejournal.com/')}

	end

	describe "OpenID.ne.jp" do
		before do
			plugin = setup_open_id_plugin('OpenID.ne.jp', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.server',
				:href => 'http://www.openid.ne.jp/user/auth')}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.delegate',
				:href => 'http://tdtds.openid.ne.jp')}

		it { expect(@header_snippet).to include_xrds_meta_tag_with(
				:content => 'http://tdtds.openid.ne.jp/user/xrds')}

	end

	describe "TypeKey" do
		before do
			plugin = setup_open_id_plugin('TypeKey', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.server',
				:href => 'http://www.typekey.com/t/openid/')}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.delegate',
				:href => 'http://profile.typekey.com/tdtds/')}

	end

	describe "Vox" do
		before do
			plugin = setup_open_id_plugin('Vox', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.server',
				:href => 'http://www.vox.com/services/openid/server')}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid.delegate',
				:href => 'http://tdtds.vox.com/')}
	end

	describe "myopenid.com" do
		before do
			@plugin = setup_open_id_plugin('myopenid.com', 'tdtds')
			@header_snippet = @plugin.header_proc
		end

		it { expect(@header_snippet).to include_xrds_meta_tag_with(
				:content => "http://www.myopenid.com/xrds?username=tdtds")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid.server",
				:href => "http://www.myopenid.com/server")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid.delegate",
				:href => "http://tdtds.myopenid.com")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid2.provider",
				:href => "http://www.myopenid.com/server")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid2.local_id",
				:href => "http://tdtds.myopenid.com")}
	end

	describe "claimID.com" do
		before do
			@plugin = setup_open_id_plugin('claimID.com', 'tdtds')
			@header_snippet = @plugin.header_proc
		end

		it { expect(@header_snippet).to include_xrds_meta_tag_with(
				:content => "http://claimid.com/tdtds/xrds")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid.server",
				:href => "http://openid.claimid.com/server")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid.delegate",
				:href => "http://openid.claimid.com/tdtds")}
	end

	describe "Personal Identity Provider (PIP)" do
		before do
			@plugin = setup_open_id_plugin('Personal Identity Provider (PIP)', 'tdtds')
			@header_snippet = @plugin.header_proc
		end

		it { expect(@header_snippet).to include_xrds_meta_tag_with(
				:content => "http://pip.verisignlabs.com/user/tdtds/yadisxrds")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid.server",
				:href => "http://pip.verisignlabs.com/server")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid.delegate",
				:href => "http://tdtds.pip.verisignlabs.com/")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid2.provider",
				:href => "http://pip.verisignlabs.com/server")}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => "openid2.local_id",
				:href => "http://tdtds.pip.verisignlabs.com/")}
	end

	describe "Yahoo! Japan" do
		before do
			plugin = setup_open_id_plugin('Yahoo! Japan', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid2.provider',
				:href => 'https://open.login.yahooapis.jp/openid/op/auth')}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid2.local_id',
				:href => 'https://me.yahoo.co.jp/a/tdtds')}

		it { expect(@header_snippet).not_to include_link_tag_with(
				:rel => "openid.server")}

		it { expect(@header_snippet).not_to include_link_tag_with(
				:rel => "openid.delegate")}

	end

	describe "Yahoo!" do
		before do
			plugin = setup_open_id_plugin('Yahoo!', 'tdtds')
			@header_snippet = plugin.header_proc
		end

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid2.provider',
				:href => 'https://open.login.yahooapis.com/openid/op/auth')}

		it { expect(@header_snippet).to include_link_tag_with(
				:rel => 'openid2.local_id',
				:href => 'https://me.yahoo.com/a/tdtds')}

		it { expect(@header_snippet).not_to include_link_tag_with(
				:rel => "openid.server")}

		it { expect(@header_snippet).not_to include_link_tag_with(
				:rel => "openid.delegate")}
	end

	RSpec::Matchers.define :include_link_tag_with do |options|
    description do
      "include #{options[:rel]} link tag"
    end

		match do |actual|
      expected = %|<link rel="#{options[:rel]}"| if options[:rel]
      expected <<= %| href="#{options[:href]}">| if options[:href]
			actual.include?( expected )
		end
	end

	RSpec::Matchers.define :include_xrds_meta_tag_with do |options|
    description do
      "include XRDS meta tag"
    end

		match do |actual|
      expected = (<<-"EOS").chomp
<meta http-equiv="X-XRDS-Location" content="#{options[:content]}">
      EOS
			actual.include?( expected )
		end
	end
end