mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
#48: add support for prompt and login_hint oauth params
This commit is contained in:
@@ -84,7 +84,8 @@ describe('AuthFlow.functional', () => {
|
||||
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 123
|
||||
clientId: 123,
|
||||
prompt: []
|
||||
}
|
||||
}
|
||||
});
|
||||
|
56
tests/services/authFlow/ChooseAccountState.test.js
Normal file
56
tests/services/authFlow/ChooseAccountState.test.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import ChooseAccountState from 'services/authFlow/ChooseAccountState';
|
||||
import CompleteState from 'services/authFlow/CompleteState';
|
||||
import LoginState from 'services/authFlow/LoginState';
|
||||
|
||||
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
|
||||
|
||||
describe('ChooseAccountState', () => {
|
||||
let state;
|
||||
let context;
|
||||
let mock;
|
||||
|
||||
beforeEach(() => {
|
||||
state = new ChooseAccountState();
|
||||
|
||||
const data = bootstrap();
|
||||
context = data.context;
|
||||
mock = data.mock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mock.verify();
|
||||
});
|
||||
|
||||
describe('#enter', () => {
|
||||
it('should navigate to /oauth/choose-account', () => {
|
||||
expectNavigate(mock, '/oauth/choose-account');
|
||||
|
||||
state.enter(context);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#resolve', () => {
|
||||
it('should transition to complete if existed account was choosen', () => {
|
||||
expectRun(mock, 'setAccountSwitcher', false);
|
||||
expectState(mock, CompleteState);
|
||||
|
||||
state.resolve(context, {id: 123});
|
||||
});
|
||||
|
||||
it('should transition to login if user wants to add new account', () => {
|
||||
expectRun(mock, 'setAccountSwitcher', false);
|
||||
expectNavigate(mock, '/login');
|
||||
expectState(mock, LoginState);
|
||||
|
||||
state.resolve(context, {});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reject', () => {
|
||||
it('should logout', () => {
|
||||
expectRun(mock, 'logout');
|
||||
|
||||
state.reject(context);
|
||||
});
|
||||
});
|
||||
});
|
@@ -144,7 +144,8 @@ describe('CompleteState', () => {
|
||||
},
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by'
|
||||
clientId: 'ely.by',
|
||||
prompt: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -166,7 +167,8 @@ describe('CompleteState', () => {
|
||||
},
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by'
|
||||
clientId: 'ely.by',
|
||||
prompt: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -194,7 +196,8 @@ describe('CompleteState', () => {
|
||||
},
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by'
|
||||
clientId: 'ely.by',
|
||||
prompt: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -225,7 +228,8 @@ describe('CompleteState', () => {
|
||||
},
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by'
|
||||
clientId: 'ely.by',
|
||||
prompt: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -242,21 +246,21 @@ describe('CompleteState', () => {
|
||||
return promise.catch(mock.verify.bind(mock));
|
||||
};
|
||||
|
||||
it('should transition to finish state if rejected with static_page', () => {
|
||||
return testOAuth('resolve', {redirectUri: 'static_page'}, FinishState);
|
||||
});
|
||||
it('should transition to finish state if rejected with static_page', () =>
|
||||
testOAuth('resolve', {redirectUri: 'static_page'}, FinishState)
|
||||
);
|
||||
|
||||
it('should transition to finish state if rejected with static_page_with_code', () => {
|
||||
return testOAuth('resolve', {redirectUri: 'static_page_with_code'}, FinishState);
|
||||
});
|
||||
it('should transition to finish state if rejected with static_page_with_code', () =>
|
||||
testOAuth('resolve', {redirectUri: 'static_page_with_code'}, FinishState)
|
||||
);
|
||||
|
||||
it('should transition to login state if rejected with unauthorized', () => {
|
||||
return testOAuth('reject', {unauthorized: true}, LoginState);
|
||||
});
|
||||
it('should transition to login state if rejected with unauthorized', () =>
|
||||
testOAuth('reject', {unauthorized: true}, LoginState)
|
||||
);
|
||||
|
||||
it('should transition to permissions state if rejected with acceptRequired', () => {
|
||||
return testOAuth('reject', {acceptRequired: true}, PermissionsState);
|
||||
});
|
||||
it('should transition to permissions state if rejected with acceptRequired', () =>
|
||||
testOAuth('reject', {acceptRequired: true}, PermissionsState)
|
||||
);
|
||||
});
|
||||
|
||||
describe('permissions accept', () => {
|
||||
@@ -285,7 +289,8 @@ describe('CompleteState', () => {
|
||||
},
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by'
|
||||
clientId: 'ely.by',
|
||||
prompt: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -309,7 +314,8 @@ describe('CompleteState', () => {
|
||||
},
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by'
|
||||
clientId: 'ely.by',
|
||||
prompt: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -337,6 +343,7 @@ describe('CompleteState', () => {
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by',
|
||||
prompt: [],
|
||||
acceptRequired: true
|
||||
}
|
||||
}
|
||||
@@ -365,6 +372,7 @@ describe('CompleteState', () => {
|
||||
auth: {
|
||||
oauth: {
|
||||
clientId: 'ely.by',
|
||||
prompt: [],
|
||||
acceptRequired: true
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@ describe('OAuthState', () => {
|
||||
response_type: 'response_type',
|
||||
description: 'description',
|
||||
scope: 'scope',
|
||||
prompt: 'none',
|
||||
login_hint: 1,
|
||||
state: 'state'
|
||||
};
|
||||
|
||||
@@ -42,6 +44,8 @@ describe('OAuthState', () => {
|
||||
responseType: query.response_type,
|
||||
description: query.description,
|
||||
scope: query.scope,
|
||||
prompt: query.prompt,
|
||||
loginHint: query.login_hint,
|
||||
state: query.state
|
||||
})
|
||||
).returns({then() {}});
|
||||
|
Reference in New Issue
Block a user