Skip to content

Commit

Permalink
Added tests and started store integration for decide page
Browse files Browse the repository at this point in the history
  • Loading branch information
dbloete committed Feb 26, 2010
1 parent b785c45 commit a220bdb
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 17 deletions.
26 changes: 16 additions & 10 deletions app/views/server/decide.html.erb
@@ -1,18 +1,24 @@
<h2><%=t :identity_request_from_host, :host => h(extract_host(@site.url)) %></h2>

<% if ax_store_request %>
<div class="attention">
<p>And do you accept following data sent from RP?</p>
<dl>
<% ax_store_request.data.each do |k,v| %>
<dt><%=h k %>:</dt>
<dd><%=h v.join(', ') %></dd>
<% end %>
</dl>
</div>
<p><%=t :trust_root_sends_some_personal_data, :trust_root => "<strong>#{h checkid_request.trust_root}</strong>" %><br />
<% if @site.persona %>
<%=t :select_information_to_submit %></p>
<ul>
<% ax_store_request.data.each do |property, value| %>
<li><%=h property %>: <%= value.join(', ') %> - currently: <%= @site.persona.property(property) %></li>
<% end %>
</ul>
<p class="note"><%=t :attributes_are_shown_from_persona, :persona => "<strong>#{h @site.persona.title}</strong>" %><br />
<%=t :to_submit_other_values_you_can_edit_or_choose,
:edit_link => link_to(t(:edit_persona_link), edit_account_persona_path(@site.persona, :return => decide_path(:persona_id => @site.persona.id))),
:choose_link => link_to_function(t(:choose_other_persona), 'Element.toggle("persona_select")') %></p>
<% else %>
<p><%=t :identity_request_missing_persona, :create_link => link_to(t(:create_persona_link), new_account_persona_path(:return => decide_path)) %></p>
<% end %>
<% if sreg_request || ax_fetch_request %>
<% elsif sreg_request || ax_fetch_request %>
<p><%=t :trust_root_requests_some_personal_data, :trust_root => "<strong>#{h checkid_request.trust_root}</strong>" %><br />
<% if @site.persona %>
<%=t :select_information_to_submit %></p>
Expand Down
4 changes: 2 additions & 2 deletions config/environment.rb
Expand Up @@ -38,8 +38,8 @@
config.time_zone = APP_CONFIG['time_zone'] || 'UTC'

# Gems
# config.gem 'ruby-openid', :lib => 'openid', :git => "http://github.com/dbloete/ruby-openid.git"
config.gem 'dbloete-ruby-openid', :lib => 'ruby-openid', :source => 'http://gems.github.com'
config.gem 'ruby-openid', :lib => 'openid'
# config.gem 'dbloete-ruby-openid', :lib => 'ruby-openid', :source => 'http://gems.github.com'
config.gem 'ruby-yadis', :lib => 'yadis'
config.gem 'mocha'

Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Expand Up @@ -197,6 +197,7 @@ de:
identity_request_from_host: Identitätsanfrage von {{host}}
identity_request_missing_persona: Bitte {{create_link}}, um die Identitätsanfrage zu beantworten.
trust_root_requests_some_personal_data: "{{trust_root}} verlangt persönliche Angaben."
trust_root_sends_some_personal_data: "{{trust_root}} sendet persönliche Angaben:"
select_information_to_submit: Bitte wählen Sie die Angaben aus, die Sie übermitteln möchten.
attributes_are_shown_from_persona: Die folgenden Angaben stammen aus Ihrer Rolle {{persona}}.
to_submit_other_values_you_can_edit_or_choose: Um andere Werte zu übermitteln können Sie {{edit_link}} oder {{choose_link}}.
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -205,6 +205,7 @@ en:
identity_request_from_host: Identity request from {{host}}
identity_request_missing_persona: Please {{create_link}} to answer the identity request.
trust_root_requests_some_personal_data: "{{trust_root}} requests some personal data."
trust_root_sends_some_personal_data: "{{trust_root}} sends some personal data:"
select_information_to_submit: Please select the information you would like to submit.
attributes_are_shown_from_persona: The attributes shown are from your persona {{persona}}.
to_submit_other_values_you_can_edit_or_choose: To submit other values you can {{edit_link}} or {{choose_link}}.
Expand Down
32 changes: 32 additions & 0 deletions test/integration/openid_user_stories_test.rb
Expand Up @@ -152,6 +152,38 @@ def test_providing_ax_data
assert @response.redirect_url_match?(@persona.gender), "Response was expected to have AX gender: #{@response.redirect_url}"
end

def test_storing_ax_data
@account = accounts(:standard)
@persona = @account.personas.first
claimed_id = "http://www.example.com/quentin"
request_params = checkid_request_params.merge(
'openid.identity' => claimed_id,
'openid.claimed_id' => claimed_id).merge(
ax_store_request_params)
# OpenID requests comes in
post '/server', request_params
# User has to log in
assert_redirected_to safe_login_url
post '/session', :login => 'quentin', :password => 'test'
# User has to verify the request
assert_redirected_to proceed_url
follow_redirect!
assert_redirected_to decide_url
follow_redirect!
assert_template 'server/decide'
post 'server/complete', :temporary => 1, :site => {
:persona_id => @persona.id }
assert @response.redirect_url_match?(checkid_request_params['openid.return_to'])
assert @response.redirect_url_match?("openid.mode=id_res"), "Response mode was expected to be id_res"
assert @response.redirect_url_match?("openid.ax.mode=store_response"), "AX mode was expected to be store_response"
# Check the attributes
@persona.reload
expected_fullname = ax_store_request_params['openid.ax.value.fullname']
expected_email = ax_store_request_params['openid.ax.value.email']
assert_equal expected_fullname, @persona.fullname, "Full name was expected to be #{expected_fullname}"
assert_equal expected_email, @persona.email, "E-mail was expected to be #{expected_email}"
end

def test_responding_to_pape_requests
claimed_id = "http://www.example.com/quentin"
request_params = checkid_request_params.merge(
Expand Down
8 changes: 3 additions & 5 deletions test/test_helper.rb
Expand Up @@ -103,7 +103,7 @@ def sreg_request_params

def ax_fetch_request_params
{ 'openid.ns.ax' => OpenID::AX::AXMessage::NS_URI,
'openid.ax.mode' => 'fetch_request',
'openid.ax.mode' => OpenID::AX::FetchRequest::MODE,
'openid.ax.type.nickname' => 'http://axschema.org/namePerson/friendly',
'openid.ax.type.gender' => 'http://axschema.org/person/gender',
'openid.ax.required' => 'nickname',
Expand All @@ -113,13 +113,11 @@ def ax_fetch_request_params

def ax_store_request_params
{ 'openid.ns.ax' => OpenID::AX::AXMessage::NS_URI,
'openid.ax.mode' => 'store_request',
'openid.ax.mode' => OpenID::AX::StoreRequest::MODE,
'openid.ax.type.fullname' => 'http://axschema.org/namePerson',
'openid.ax.value.fullname' => 'Bob Smith',
'openid.ax.type.email' => 'http://axschema.org/contact/email',
'openid.ax.count.email' => '2',
'openid.ax.value.email.1' => 'mail@mydomain.com',
'openid.ax.value.email.2' => 'info@mydomain.com' }
'openid.ax.value.email' => 'mail@mydomain.com' }
end

def pape_request_params
Expand Down

0 comments on commit a220bdb

Please sign in to comment.