root/platform/tdiary/spec/openid_spec.rb

Revision 18894, 7.5 kB (checked in by hsbt, 3 months ago)

add service for wassr openid.

Line 
1$:.unshift(File.dirname(__FILE__))
2require 'spec_helper'
3
4describe "openid plugin w/" do
5        def setup_open_id_plugin(service, userid)
6                fake_plugin(:openid) { |plugin|
7                        plugin.mode = 'latest'
8                        plugin.conf['openid.service'] = service
9                        plugin.conf['openid.id'] = userid
10                }
11        end
12
13        describe "Hatena" do
14                before do
15                        plugin = setup_open_id_plugin('Hatena', 'tdtds')
16                        @header_snippet = plugin.header_proc
17                end
18
19                it { @header_snippet.should include_link_tag_with(
20                                :rel => 'openid.server',
21                                :href => 'https://www.hatena.ne.jp/openid/server')}
22
23                it { @header_snippet.should include_link_tag_with(
24                                :rel => 'openid.delegate',
25                                :href => 'http://www.hatena.ne.jp/tdtds/')}
26        end
27
28        describe "livedoor" do
29                before do
30                        plugin = setup_open_id_plugin('livedoor', 'tdtds')
31                        @header_snippet = plugin.header_proc
32                end
33
34                it { @header_snippet.should include_link_tag_with(
35                                :rel => 'openid.server',
36                                :href => 'http://auth.livedoor.com/openid/server')}
37
38                it { @header_snippet.should include_link_tag_with(
39                        :rel => 'openid.delegate',
40                        :href => 'http://profile.livedoor.com/tdtds')}
41        end
42
43        describe "LiveJournal" do
44                before do
45                        plugin = setup_open_id_plugin('LiveJournal', 'tdtds')
46                        @header_snippet = plugin.header_proc
47                end
48
49                it { @header_snippet.should include_link_tag_with(
50                                :rel => 'openid.server',
51                                :href => 'http://www.livejournal.com/openid/server.bml')}
52
53                it { @header_snippet.should include_link_tag_with(
54                                :rel => 'openid.delegate',
55                                :href => 'http://tdtds.livejournal.com/')}
56
57        end
58
59        describe "OpenID.ne.jp" do
60                before do
61                        plugin = setup_open_id_plugin('OpenID.ne.jp', 'tdtds')
62                        @header_snippet = plugin.header_proc
63                end
64
65                it { @header_snippet.should include_link_tag_with(
66                                :rel => 'openid.server',
67                                :href => 'http://www.openid.ne.jp/user/auth')}
68
69                it { @header_snippet.should include_link_tag_with(
70                                :rel => 'openid.delegate',
71                                :href => 'http://tdtds.openid.ne.jp')}
72
73                it { @header_snippet.should include_xrds_meta_tag_with(
74                                :content => 'http://tdtds.openid.ne.jp/user/xrds')}
75
76        end
77
78        describe "TypeKey" do
79                before do
80                        plugin = setup_open_id_plugin('TypeKey', 'tdtds')
81                        @header_snippet = plugin.header_proc
82                end
83
84                it { @header_snippet.should include_link_tag_with(
85                                :rel => 'openid.server',
86                                :href => 'http://www.typekey.com/t/openid/')}
87
88                it { @header_snippet.should include_link_tag_with(
89                                :rel => 'openid.delegate',
90                                :href => 'http://profile.typekey.com/tdtds/')}
91
92        end
93
94        describe "Videntity.org" do
95                before do
96                        plugin = setup_open_id_plugin('Videntity.org', 'tdtds')
97                        @header_snippet = plugin.header_proc
98                end
99
100                it { @header_snippet.should include_link_tag_with(
101                                :rel => 'openid.server',
102                                :href => 'http://videntity.org/serverlogin?action=openid')}
103
104                it { @header_snippet.should include_link_tag_with(
105                                :rel => 'openid.delegate',
106                                :href => 'http://tdtds.videntity.org/')}
107
108        end
109
110        describe "Vox" do
111                before do
112                        plugin = setup_open_id_plugin('Vox', 'tdtds')
113                        @header_snippet = plugin.header_proc
114                end
115
116                it { @header_snippet.should include_link_tag_with(
117                                :rel => 'openid.server',
118                                :href => 'http://www.vox.com/services/openid/server')}
119
120                it { @header_snippet.should include_link_tag_with(
121                                :rel => 'openid.delegate',
122                                :href => 'http://tdtds.vox.com/')}
123        end
124
125        describe "myopenid.com" do
126                before do
127                        @plugin = setup_open_id_plugin('myopenid.com', 'tdtds')
128                        @header_snippet = @plugin.header_proc
129                end
130
131                it { @header_snippet.should include_xrds_meta_tag_with(
132                                :content => "http://www.myopenid.com/xrds?username=tdtds")}
133
134                it { @header_snippet.should include_link_tag_with(
135                                :rel => "openid.server",
136                                :href => "http://www.myopenid.com/server")}
137
138                it { @header_snippet.should include_link_tag_with(
139                                :rel => "openid.delegate",
140                                :href => "http://tdtds.myopenid.com")}
141
142                it { @header_snippet.should include_link_tag_with(
143                                :rel => "openid2.provider",
144                                :href => "http://www.myopenid.com/server")}
145
146                it { @header_snippet.should include_link_tag_with(
147                                :rel => "openid2.local_id",
148                                :href => "http://tdtds.myopenid.com")}
149        end
150
151        describe "claimID.com" do
152                before do
153                        @plugin = setup_open_id_plugin('claimID.com', 'tdtds')
154                        @header_snippet = @plugin.header_proc
155                end
156
157                it { @header_snippet.should include_xrds_meta_tag_with(
158                                :content => "http://claimid.com/tdtds/xrds")}
159
160                it { @header_snippet.should include_link_tag_with(
161                                :rel => "openid.server",
162                                :href => "http://openid.claimid.com/server")}
163
164                it { @header_snippet.should include_link_tag_with(
165                                :rel => "openid.delegate",
166                                :href => "http://openid.claimid.com/tdtds")}
167        end
168
169        describe "Personal Identity Provider (PIP)" do
170                before do
171                        @plugin = setup_open_id_plugin('Personal Identity Provider (PIP)', 'tdtds')
172                        @header_snippet = @plugin.header_proc
173                end
174
175                it { @header_snippet.should include_xrds_meta_tag_with(
176                                :content => "http://pip.verisignlabs.com/user/tdtds/yadisxrds")}
177
178                it { @header_snippet.should include_link_tag_with(
179                                :rel => "openid.server",
180                                :href => "http://pip.verisignlabs.com/server")}
181
182                it { @header_snippet.should include_link_tag_with(
183                                :rel => "openid.delegate",
184                                :href => "http://tdtds.pip.verisignlabs.com/")}
185
186                it { @header_snippet.should include_link_tag_with(
187                                :rel => "openid2.provider",
188                                :href => "http://pip.verisignlabs.com/server")}
189
190                it { @header_snippet.should include_link_tag_with(
191                                :rel => "openid2.local_id",
192                                :href => "http://tdtds.pip.verisignlabs.com/")}
193        end
194
195        describe "Yahoo! Japan" do
196                before do
197                        plugin = setup_open_id_plugin('Yahoo! Japan', 'tdtds')
198                        @header_snippet = plugin.header_proc
199                end
200
201                it { @header_snippet.should include_link_tag_with(
202                                :rel => 'openid2.provider',
203                                :href => 'https://open.login.yahooapis.jp/openid/op/auth')}
204
205                it { @header_snippet.should include_link_tag_with(
206                                :rel => 'openid2.local_id',
207                                :href => 'https://me.yahoo.co.jp/a/tdtds')}
208
209                it { @header_snippet.should_not include_link_tag_with(
210                                :rel => "openid.server")}
211
212                it { @header_snippet.should_not include_link_tag_with(
213                                :rel => "openid.delegate")}
214
215        end
216
217        describe "Yahoo!" do
218                before do
219                        plugin = setup_open_id_plugin('Yahoo!', 'tdtds')
220                        @header_snippet = plugin.header_proc
221                end
222
223                it { @header_snippet.should include_link_tag_with(
224                                :rel => 'openid2.provider',
225                                :href => 'https://open.login.yahooapis.com/openid/op/auth')}
226
227                it { @header_snippet.should include_link_tag_with(
228                                :rel => 'openid2.local_id',
229                                :href => 'https://me.yahoo.com/a/tdtds')}
230
231                it { @header_snippet.should_not include_link_tag_with(
232                                :rel => "openid.server")}
233
234                it { @header_snippet.should_not include_link_tag_with(
235                                :rel => "openid.delegate")}
236        end
237
238        describe "Wassr" do
239                before do
240                        plugin = setup_open_id_plugin('Wassr', 'tdtds')
241                        @header_snippet = plugin.header_proc
242                end
243
244                it { @header_snippet.should include_link_tag_with(
245                                :rel => 'openid.server',
246                                :href => 'https://wassr.jp/open_id/auth')}
247
248                it { @header_snippet.should include_link_tag_with(
249                                :rel => 'openid.delegate',
250                                :href => 'https://wassr.jp/user/tdtds')}
251        end
252
253        def include_link_tag_with(options)
254                msg = "include #{options[:rel]} link tag"
255                expected = %|<link rel="#{options[:rel]}"| if options[:rel]
256                expected <<= %| href="#{options[:href]}">| if options[:href]
257                        Spec::Matchers::SimpleMatcher.new(msg) do |actual|
258                        actual.include?( expected )
259                end
260        end
261
262        def include_xrds_meta_tag_with(options)
263                msg = "include XRDS meta tag"
264                expected = (<<-"EOS").chomp
265<meta http-equiv="X-XRDS-Location" content="#{options[:content]}">
266      EOS
267                Spec::Matchers::SimpleMatcher.new(msg) do |actual|
268                                actual.include?( expected )
269                end
270        end
271
272end
Note: See TracBrowser for help on using the browser.