kraut 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +11 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +3 -0
  4. data/README.md +175 -0
  5. data/Rakefile +10 -0
  6. data/app/controllers/kraut/sessions_controller.rb +30 -0
  7. data/app/models/kraut/session.rb +67 -0
  8. data/app/views/kraut/sessions/new.html.haml +15 -0
  9. data/autotest/discover.rb +1 -0
  10. data/config/initializers/savon.rb +12 -0
  11. data/config/locales/kraut.yml +14 -0
  12. data/config/routes.rb +5 -0
  13. data/kraut.gemspec +43 -0
  14. data/lib/kraut.rb +3 -0
  15. data/lib/kraut/application.rb +31 -0
  16. data/lib/kraut/client.rb +63 -0
  17. data/lib/kraut/kraut.rb +21 -0
  18. data/lib/kraut/mapper.rb +20 -0
  19. data/lib/kraut/principal.rb +85 -0
  20. data/lib/kraut/rails/authentication.rb +80 -0
  21. data/lib/kraut/rails/engine.rb +29 -0
  22. data/lib/kraut/rails/spec/login_helper.rb +28 -0
  23. data/lib/kraut/rails/spec/protected_action.rb +68 -0
  24. data/lib/kraut/rails/spec/user_helper.rb +27 -0
  25. data/lib/kraut/rails/spec_helper.rb +15 -0
  26. data/lib/kraut/version.rb +6 -0
  27. data/spec/controllers/application_controller_spec.rb +219 -0
  28. data/spec/controllers/sessions_controller_spec.rb +106 -0
  29. data/spec/fixtures/authenticate_application/invalid_app.xml +11 -0
  30. data/spec/fixtures/authenticate_application/invalid_password.xml +11 -0
  31. data/spec/fixtures/authenticate_application/success.xml +10 -0
  32. data/spec/fixtures/authenticate_principal/application_access_denied.xml +11 -0
  33. data/spec/fixtures/authenticate_principal/invalid_password.xml +11 -0
  34. data/spec/fixtures/authenticate_principal/invalid_user.xml +11 -0
  35. data/spec/fixtures/authenticate_principal/success.xml +7 -0
  36. data/spec/fixtures/find_principal_by_token/invalid_token.xml +11 -0
  37. data/spec/fixtures/find_principal_by_token/success.xml +39 -0
  38. data/spec/fixtures/find_principal_with_attributes_by_name/invalid_user.xml +11 -0
  39. data/spec/fixtures/find_principal_with_attributes_by_name/success.xml +69 -0
  40. data/spec/fixtures/is_group_member/not_in_group.xml +8 -0
  41. data/spec/fixtures/is_group_member/success.xml +8 -0
  42. data/spec/kraut/application_spec.rb +99 -0
  43. data/spec/kraut/client_spec.rb +101 -0
  44. data/spec/kraut/mapper_spec.rb +48 -0
  45. data/spec/kraut/principal_spec.rb +142 -0
  46. data/spec/models/session_spec.rb +148 -0
  47. data/spec/rails/engine_spec.rb +24 -0
  48. data/spec/spec_helper.rb +33 -0
  49. data/spec/views/sessions/new.html.haml_spec.rb +11 -0
  50. metadata +237 -0
@@ -0,0 +1,106 @@
1
+ require "spec_helper"
2
+
3
+ describe Kraut::SessionsController do
4
+
5
+ describe "routing" do
6
+ it "should route to new" do
7
+ { :get => "/sessions/new" }.
8
+ should route_to(:controller => "kraut/sessions", :action => "new")
9
+ end
10
+
11
+ it "should route to create" do
12
+ { :post => "/sessions" }.
13
+ should route_to(:controller => "kraut/sessions", :action => "create")
14
+ end
15
+
16
+ it "should route to destroy" do
17
+ { :delete => "/sessions" }.
18
+ should route_to(:controller => "kraut/sessions", :action => "destroy")
19
+ end
20
+ end
21
+
22
+ describe "GET :new" do
23
+ it "should assign a session" do
24
+ get :new
25
+ assigns[:session].should be_a(Kraut::Session)
26
+ end
27
+ end
28
+
29
+ describe "POST :create" do
30
+ before do
31
+ @user = Kraut::Session.new
32
+ Kraut::Session.expects(:new).returns(@user)
33
+ controller.expects(:authenticate_application)
34
+ Kraut::Rails::Engine.config.entry_url = "/blu"
35
+ end
36
+
37
+ context "with valid credentials" do
38
+ context "and :stored_location is not set" do
39
+ before do
40
+ @user.expects(:valid?).returns(true)
41
+ post :create
42
+ end
43
+
44
+ it "should store the new session" do
45
+ controller.user.should == @user
46
+ end
47
+
48
+ it "should redirect to configured entry_url" do
49
+ response.should redirect_to("/blu")
50
+ end
51
+ end
52
+
53
+ context "and :stored_location is set" do
54
+ before do
55
+ @user.expects(:valid?).returns(true)
56
+ session[:stored_location] = "/url/we/want"
57
+ post :create
58
+ end
59
+
60
+ it "should store the new session" do
61
+ controller.user.should == @user
62
+ end
63
+
64
+ it "should redirect to :stored_location" do
65
+ response.should redirect_to("/url/we/want")
66
+ end
67
+
68
+ it "should delete the :stored_location parameter" do
69
+ session[:stored_location].should be_nil
70
+ end
71
+ end
72
+ end
73
+
74
+ context "with invalid credentials" do
75
+ before do
76
+ @user.expects(:valid?).returns(false)
77
+ session[:stored_location] = "/url/we/want"
78
+ post :create
79
+ end
80
+
81
+ it "should not store the new session" do
82
+ controller.user.should be_nil
83
+ end
84
+
85
+ it "should render the :new action" do
86
+ response.should render_template(:new)
87
+ end
88
+
89
+ it "should not delete the :stored_location parameter" do
90
+ session[:stored_location].should_not be_nil
91
+ end
92
+ end
93
+ end
94
+
95
+ describe "DELETE :destroy" do
96
+ it "should logout, reset the session and redirect to configured entry_url" do
97
+ controller.switch_user(Kraut::Session.new)
98
+ Kraut::Rails::Engine.config.entry_url = "/bla"
99
+ delete :destroy
100
+ controller.logged_in?.should == false
101
+ session.should == {}
102
+ response.should redirect_to("/bla")
103
+ end
104
+ end
105
+
106
+ end
@@ -0,0 +1,11 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Server</faultcode>
5
+ <faultstring>Failed to find entity of type [com.atlassian.crowd.model.application.Application] with identifier [invalid]</faultstring>
6
+ <detail>
7
+ <InvalidAuthenticationException xmlns="urn:SecurityServer"/>
8
+ </detail>
9
+ </soap:Fault>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,11 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Server</faultcode>
5
+ <faultstring>The password in the application's crowd.properties file does not match the password in Crowd. Application with invalid password: app</faultstring>
6
+ <detail>
7
+ <InvalidAuthenticationException xmlns="urn:SecurityServer"/>
8
+ </detail>
9
+ </soap:Fault>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,10 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <ns1:authenticateApplicationResponse xmlns:ns1="urn:SecurityServer">
4
+ <ns1:out>
5
+ <name xmlns="http://authentication.integration.crowd.atlassian.com">app</name>
6
+ <token xmlns="http://authentication.integration.crowd.atlassian.com">J8n5KCem7Djk30zel0rUdA00</token>
7
+ </ns1:out>
8
+ </ns1:authenticateApplicationResponse>
9
+ </soap:Body>
10
+ </soap:Envelope>
@@ -0,0 +1,11 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Server</faultcode>
5
+ <faultstring>com.atlassian.crowd.manager.application.ApplicationAccessDeniedException: User does not have access to application my-app</faultstring>
6
+ <detail>
7
+ <ApplicationAccessDeniedException xmlns="urn:SecurityServer" />
8
+ </detail>
9
+ </soap:Fault>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,11 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Server</faultcode>
5
+ <faultstring>Failed to authenticate principal, password was invalid</faultstring>
6
+ <detail>
7
+ <InvalidAuthenticationException xmlns="urn:SecurityServer"/>
8
+ </detail>
9
+ </soap:Fault>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,11 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Server</faultcode>
5
+ <faultstring>Failed to find entity of type [com.atlassian.crowd.model.application.Application] with identifier [unknown]</faultstring>
6
+ <detail>
7
+ <InvalidAuthenticationException xmlns="urn:SecurityServer"/>
8
+ </detail>
9
+ </soap:Fault>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,7 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <ns1:authenticatePrincipalResponse xmlns:ns1="urn:SecurityServer">
4
+ <ns1:out>COvlhb092poBHXi4rh4PQg00</ns1:out>
5
+ </ns1:authenticatePrincipalResponse>
6
+ </soap:Body>
7
+ </soap:Envelope>
@@ -0,0 +1,11 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Server</faultcode>
5
+ <faultstring>Failed to find entity of type [com.atlassian.crowd.model.token.Token] with identifier [0d0hWMoxDJLsO05lX06oKA02]</faultstring>
6
+ <detail>
7
+ <InvalidTokenException xmlns="urn:SecurityServer"/>
8
+ </detail>
9
+ </soap:Fault>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,39 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <ns1:findPrincipalByTokenResponse xmlns:ns1="urn:SecurityServer">
4
+ <ns1:out>
5
+ <ID xmlns="http://soap.integration.crowd.atlassian.com">-1</ID>
6
+ <active xmlns="http://soap.integration.crowd.atlassian.com">true</active>
7
+ <attributes xmlns="http://soap.integration.crowd.atlassian.com">
8
+ <SOAPAttribute>
9
+ <name>givenName</name>
10
+ <values>
11
+ <ns1:string>Test</ns1:string>
12
+ </values>
13
+ </SOAPAttribute>
14
+ <SOAPAttribute>
15
+ <name>sn</name>
16
+ <values>
17
+ <ns1:string>Supervisor</ns1:string>
18
+ </values>
19
+ </SOAPAttribute>
20
+ <SOAPAttribute>
21
+ <name>displayName</name>
22
+ <values>
23
+ <ns1:string>Test Supervisor</ns1:string>
24
+ </values>
25
+ </SOAPAttribute>
26
+ <SOAPAttribute>
27
+ <name>mail</name>
28
+ <values>
29
+ <ns1:string>no_reply@blau.de</ns1:string>
30
+ </values>
31
+ </SOAPAttribute>
32
+ </attributes>
33
+ <description xsi:nil="true" xmlns="http://soap.integration.crowd.atlassian.com"/>
34
+ <directoryId xmlns="http://soap.integration.crowd.atlassian.com">32769</directoryId>
35
+ <name xmlns="http://soap.integration.crowd.atlassian.com">test-supervisor</name>
36
+ </ns1:out>
37
+ </ns1:findPrincipalByTokenResponse>
38
+ </soap:Body>
39
+ </soap:Envelope>
@@ -0,0 +1,11 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <faultcode>soap:Server</faultcode>
5
+ <faultstring>Failed to find entity of type [com.atlassian.crowd.integration.model.user.User] with identifier [unknown]</faultstring>
6
+ <detail>
7
+ <ObjectNotFoundException xmlns="urn:SecurityServer"/>
8
+ </detail>
9
+ </soap:Fault>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,69 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <ns1:findPrincipalWithAttributesByNameResponse xmlns:ns1="urn:SecurityServer">
4
+ <ns1:out>
5
+ <ID xmlns="http://soap.integration.crowd.atlassian.com">-1</ID>
6
+ <active xmlns="http://soap.integration.crowd.atlassian.com">true</active>
7
+ <attributes xmlns="http://soap.integration.crowd.atlassian.com">
8
+ <SOAPAttribute>
9
+ <name>givenName</name>
10
+ <values>
11
+ <ns1:string>Test</ns1:string>
12
+ </values>
13
+ </SOAPAttribute>
14
+ <SOAPAttribute>
15
+ <name>sn</name>
16
+ <values>
17
+ <ns1:string>User</ns1:string>
18
+ </values>
19
+ </SOAPAttribute>
20
+ <SOAPAttribute>
21
+ <name>displayName</name>
22
+ <values>
23
+ <ns1:string>Test User</ns1:string>
24
+ </values>
25
+ </SOAPAttribute>
26
+ <SOAPAttribute>
27
+ <name>mail</name>
28
+ <values>
29
+ <ns1:string>test@blau.de</ns1:string>
30
+ </values>
31
+ </SOAPAttribute>
32
+ <SOAPAttribute>
33
+ <name>requiresPasswordChange</name>
34
+ <values>
35
+ <ns1:string>false</ns1:string>
36
+ </values>
37
+ </SOAPAttribute>
38
+ <SOAPAttribute>
39
+ <name>invalidPasswordAttempts</name>
40
+ <values>
41
+ <ns1:string>0</ns1:string>
42
+ </values>
43
+ </SOAPAttribute>
44
+ <SOAPAttribute>
45
+ <name>lastAuthenticated</name>
46
+ <values>
47
+ <ns1:string>1286895918952</ns1:string>
48
+ </values>
49
+ </SOAPAttribute>
50
+ <SOAPAttribute>
51
+ <name>passwordLastChanged</name>
52
+ <values>
53
+ <ns1:string>1274258741546</ns1:string>
54
+ </values>
55
+ </SOAPAttribute>
56
+ <SOAPAttribute>
57
+ <name>inexsoUserId</name>
58
+ <values>
59
+ <ns1:string>107</ns1:string>
60
+ </values>
61
+ </SOAPAttribute>
62
+ </attributes>
63
+ <description xsi:nil="true" xmlns="http://soap.integration.crowd.atlassian.com"/>
64
+ <directoryId xmlns="http://soap.integration.crowd.atlassian.com">32769</directoryId>
65
+ <name xmlns="http://soap.integration.crowd.atlassian.com">test</name>
66
+ </ns1:out>
67
+ </ns1:findPrincipalWithAttributesByNameResponse>
68
+ </soap:Body>
69
+ </soap:Envelope>
@@ -0,0 +1,8 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <ns1:isGroupMemberResponse xmlns:ns1="urn:SecurityServer">
4
+ <ns1:out>false</ns1:out>
5
+ </ns1:isGroupMemberResponse>
6
+ </soap:Body>
7
+ </soap:Envelope>
8
+
@@ -0,0 +1,8 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
+ <soap:Body>
3
+ <ns1:isGroupMemberResponse xmlns:ns1="urn:SecurityServer">
4
+ <ns1:out>true</ns1:out>
5
+ </ns1:isGroupMemberResponse>
6
+ </soap:Body>
7
+ </soap:Envelope>
8
+
@@ -0,0 +1,99 @@
1
+ require "spec_helper"
2
+ require "kraut/application"
3
+
4
+ describe Kraut::Application do
5
+ let(:application) { Kraut::Application }
6
+
7
+ before do
8
+ savon.expects(:authenticate_application).returns(:success)
9
+ Kraut::Application.authenticate "app", "password"
10
+ end
11
+
12
+ describe ".authenticate" do
13
+ it "should return the application credentials" do
14
+ savon.expects(:authenticate_application).returns(:success)
15
+
16
+ credentials = application.authenticate "app", "password"
17
+ credentials.should == ["app", "password", "J8n5KCem7Djk30zel0rUdA00"]
18
+ end
19
+
20
+ it "should set the application name" do
21
+ application.name.should == "app"
22
+ end
23
+
24
+ it "should set the application password" do
25
+ application.password.should == "password"
26
+ end
27
+
28
+ it "should set the authentication token" do
29
+ application.token.should == "J8n5KCem7Djk30zel0rUdA00"
30
+ end
31
+
32
+ it "should set the last authentication time" do
33
+ application.authenticated_at.should be_a(Time)
34
+ end
35
+
36
+ context "in case of an invalid application name" do
37
+ before { savon.expects(:authenticate_application).returns(:invalid_app) }
38
+
39
+ it "should raise an InvalidAuthentication error" do
40
+ lambda { Kraut::Application.authenticate "invalid", "invalid" }.
41
+ should raise_error(Kraut::InvalidAuthentication, /with identifier \[invalid\]/)
42
+ end
43
+ end
44
+
45
+ context "in case of an invalid password" do
46
+ before { savon.expects(:authenticate_application).returns(:invalid_password) }
47
+
48
+ it "should raise an InvalidAuthentication error" do
49
+ lambda { Kraut::Application.authenticate "app", "invalid" }.
50
+ should raise_error(Kraut::InvalidAuthentication, /Application with invalid password/)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe ".name" do
56
+ it "should contain the application name" do
57
+ application.name.should == "app"
58
+ end
59
+ end
60
+
61
+ describe ".password" do
62
+ it "should contain the application password" do
63
+ application.password.should == "password"
64
+ end
65
+ end
66
+
67
+ describe ".token" do
68
+ it "should contain the authentication token" do
69
+ application.token.should == "J8n5KCem7Djk30zel0rUdA00"
70
+ end
71
+ end
72
+
73
+ describe ".authentication_required?" do
74
+ context "when not authenticated" do
75
+ before { Kraut::Application.authenticated_at = nil }
76
+
77
+ it "should return true" do
78
+ application.authentication_required?.should == true
79
+ end
80
+ end
81
+
82
+ context "when authentication expired (default timeout = 10 min)" do
83
+ before { Kraut::Application.authenticated_at = Time.now - (60 * 11) }
84
+
85
+ it "should return true" do
86
+ application.authentication_required?.should == true
87
+ end
88
+ end
89
+
90
+ context "when authenticated" do
91
+ before { Kraut::Application.authenticated_at = Time.now }
92
+
93
+ it "should return false" do
94
+ application.authentication_required?.should == false
95
+ end
96
+ end
97
+ end
98
+
99
+ end
@@ -0,0 +1,101 @@
1
+ require "spec_helper"
2
+ require "kraut/client"
3
+
4
+ describe Kraut::Client do
5
+
6
+ shared_examples_for "a Kraut::Client" do
7
+ context "when receiving an ApplicationAccessDenied error" do
8
+ it "should raise a Kraut::ApplicationAccessDenied error" do
9
+ savon.expects(:authenticate_principal).returns(:application_access_denied)
10
+ expect { subject.request :authenticate_principal, :some => :request }.to raise_error(Kraut::ApplicationAccessDenied)
11
+ end
12
+ end
13
+
14
+ context "when receiving an InvalidAuthentication error" do
15
+ it "should raise a Kraut::InvalidAuthentication error" do
16
+ savon.expects(:authenticate_principal).returns(:invalid_user)
17
+ expect { subject.request :authenticate_principal, :some => :request }.to raise_error(Kraut::InvalidAuthentication)
18
+ end
19
+ end
20
+ end
21
+
22
+ describe ".request" do
23
+ context "when successful" do
24
+ before do
25
+ savon.expects(:authenticate_application).with(
26
+ :in0 => { "aut:credential" => { "aut:credential" => "password" }, "aut:name" => "name" }
27
+ ).returns(:success)
28
+ end
29
+
30
+ it "should return the response as a Hash" do
31
+ result = subject.request :authenticate_application, :in0 => {
32
+ "aut:credential" => { "aut:credential" => "password" }, "aut:name" => "name"
33
+ }
34
+
35
+ result.should include(:out => { :token => "J8n5KCem7Djk30zel0rUdA00", :name => "app" })
36
+ end
37
+ end
38
+
39
+ context "when Savon raises errors" do
40
+ it_should_behave_like "a Kraut::Client"
41
+ end
42
+
43
+ context "when Savon does not raise errors" do
44
+ it_should_behave_like "a Kraut::Client"
45
+ end
46
+ end
47
+
48
+ describe ".auth_request" do
49
+ context "when successful" do
50
+ before do
51
+ Kraut::Application.expects(:name).returns("app")
52
+ Kraut::Application.expects(:token).returns("J8n5KCem7Djk30zel0rUdA00")
53
+
54
+ savon.expects(:authenticate_principal).with(
55
+ :in0 => { "aut:name" => "app", "aut:token" => "J8n5KCem7Djk30zel0rUdA00" },
56
+ :in1 => {
57
+ "aut:application" => "app",
58
+ "aut:credential" => { "aut:credential" => "password" }, "aut:name" => "name"
59
+ },
60
+ :order! => [:in0, :in1]
61
+ ).returns(:success)
62
+ end
63
+
64
+ it "should return the response as a Hash" do
65
+ result = subject.auth_request :authenticate_principal, :in1 => {
66
+ "aut:application" => "app",
67
+ "aut:credential" => { "aut:credential" => "password" }, "aut:name" => "name"
68
+ }
69
+
70
+ result.should include(:out => "COvlhb092poBHXi4rh4PQg00")
71
+ end
72
+ end
73
+
74
+ context "when Savon raises errors" do
75
+ it_should_behave_like "a Kraut::Client"
76
+ end
77
+
78
+ context "when Savon does not raise errors" do
79
+ it_should_behave_like "a Kraut::Client"
80
+ end
81
+ end
82
+
83
+ describe ".client" do
84
+ it "should return a Savon::Client instance" do
85
+ Kraut::Client.client.should be_a(Savon::Client)
86
+ end
87
+
88
+ it "should memoize the Savon::Client instance" do
89
+ Kraut::Client.client.should equal(Kraut::Client.client)
90
+ end
91
+
92
+ it "should set the SOAP endpoint" do
93
+ Kraut::Client.client.wsdl.endpoint.should == Kraut.endpoint
94
+ end
95
+
96
+ it "should set the target namespace" do
97
+ Kraut::Client.client.wsdl.namespace.should == "urn:SecurityServer"
98
+ end
99
+ end
100
+
101
+ end