mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Update spec/requests/authentication_spec.rb
This commit is contained in:
parent
c0e756d085
commit
5347232376
1 changed files with 7 additions and 12 deletions
|
|
@ -69,19 +69,15 @@ RSpec.describe 'Authentication', type: :request do
|
||||||
|
|
||||||
describe 'Mobile iOS Authentication' do
|
describe 'Mobile iOS Authentication' do
|
||||||
it 'redirects to iOS success path when signing in with iOS client header' do
|
it 'redirects to iOS success path when signing in with iOS client header' do
|
||||||
# Sign in with iOS client header
|
# Make a login request with the iOS client header (user NOT pre-signed in)
|
||||||
sign_in user
|
|
||||||
|
|
||||||
# Mock the after_sign_in_path_for redirect behavior
|
|
||||||
allow_any_instance_of(ApplicationController).to receive(:after_sign_in_path_for).and_return(ios_success_path)
|
|
||||||
|
|
||||||
# Make a request with the iOS client header
|
|
||||||
post user_session_path, params: {
|
post user_session_path, params: {
|
||||||
user: { email: user.email, password: 'password123' }
|
user: { email: user.email, password: 'password123' }
|
||||||
}, headers: { 'X-Dawarich-Client' => 'ios' }
|
}, headers: { 'X-Dawarich-Client' => 'ios' }
|
||||||
|
|
||||||
# Should redirect to iOS success endpoint after successful login
|
# Should redirect to iOS success endpoint after successful login
|
||||||
expect(response).to redirect_to(ios_success_path)
|
# The redirect will include a token parameter generated by after_sign_in_path_for
|
||||||
|
expect(response).to redirect_to(%r{auth/ios/success\?token=})
|
||||||
|
expect(response.location).to include('token=')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns JSON response with JWT token for iOS success endpoint' do
|
it 'returns JSON response with JWT token for iOS success endpoint' do
|
||||||
|
|
@ -127,15 +123,14 @@ RSpec.describe 'Authentication', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'uses default path for non-iOS clients' do
|
it 'uses default path for non-iOS clients' do
|
||||||
sign_in user
|
# Make a login request without iOS client header (user NOT pre-signed in)
|
||||||
|
|
||||||
# Make a request without iOS client header
|
|
||||||
post user_session_path, params: {
|
post user_session_path, params: {
|
||||||
user: { email: user.email, password: 'password123' }
|
user: { email: user.email, password: 'password123' }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Should redirect to default path (not iOS success)
|
# Should redirect to default path (not iOS success)
|
||||||
expect(response).not_to redirect_to(ios_success_path)
|
expect(response).not_to redirect_to(%r{auth/ios/success})
|
||||||
|
expect(response.location).not_to include('auth/ios/success')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue