File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -92,11 +92,13 @@ def configure_database_connection
92
92
def prepare_app
93
93
configure_middleware
94
94
95
+ # need this first so UI login logic is performed before API login logic
96
+ @cascade_apps << build_ui
97
+
95
98
if configuration . enable_diagnostic_endpoints
96
99
@cascade_apps << build_diagnostic
97
100
end
98
101
99
- @cascade_apps << build_ui
100
102
@cascade_apps << build_api
101
103
end
102
104
Original file line number Diff line number Diff line change @@ -107,6 +107,31 @@ def call(env)
107
107
expect ( last_response . headers [ "WWW-Authenticate" ] ) . to eq "Basic realm=\" Protected\" "
108
108
end
109
109
end
110
+
111
+ context "ordering of calls" do
112
+ class TestAuth1
113
+ def initialize app ; end
114
+ def call env ; end
115
+ end
116
+
117
+ class TestAuth2 < TestAuth1 ; end
118
+
119
+ before do
120
+ allow ( TestAuth1 ) . to receive ( :new ) . and_return ( test_auth_1 )
121
+ allow ( TestAuth2 ) . to receive ( :new ) . and_return ( test_auth_2 )
122
+ end
123
+
124
+ let ( :test_auth_1 ) { instance_double ( 'TestAuth1' , call : [ 404 , { } , [ ] ] ) }
125
+ let ( :test_auth_2 ) { instance_double ( 'TestAuth2' , call : [ 404 , { } , [ ] ] ) }
126
+
127
+ it "calls the UI auth before the API auth" do
128
+ expect ( test_auth_1 ) . to receive ( :call ) . ordered
129
+ expect ( test_auth_2 ) . to receive ( :call ) . ordered
130
+ app . use_ui_auth TestAuth1
131
+ app . use_api_auth TestAuth2
132
+ get "/" , nil , { 'HTTP_ACCEPT' => 'text/html' }
133
+ end
134
+ end
110
135
end
111
136
112
137
describe "authenticate" do
You can’t perform that action at this time.
0 commit comments