1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

chore: sasjs login fix

This commit is contained in:
2022-04-29 12:40:38 +02:00
parent fdd3a261e5
commit a97b2f43ca
2 changed files with 34 additions and 35 deletions

View File

@@ -11,7 +11,7 @@ const Login = (): ReactElement<{}> => {
const handleSubmit = useCallback(
(e) => {
e.preventDefault()
appContext.adapter.logIn(username, password).then((res) => {
appContext.adapter.logIn(username, password, 'clientID1').then((res) => {
appContext.setIsLoggedIn(res.isLoggedIn)
})
},

View File

@@ -33,41 +33,40 @@ export const basicTests = (
): TestSuite => ({
name: 'Basic Tests',
tests: [
// LOGIN TESTS DISABLED UNTIL SASJS SERVER MODE NOT FIXED
// {
// title: 'Log in',
// description: 'Should log the user in',
// test: async () => {
// return adapter.logIn(userName, password)
// },
// assertion: (response: any) =>
// response && response.isLoggedIn && response.userName === userName
// },
// {
// title: 'Fetch username for already logged in user',
// description: 'Should log the user in',
// test: async () => {
// await adapter.logIn(userName, password)
{
title: 'Log in',
description: 'Should log the user in',
test: async () => {
return adapter.logIn(userName, password, 'clientID1')
},
assertion: (response: any) =>
response && response.isLoggedIn && response.userName === userName
},
{
title: 'Fetch username for already logged in user',
description: 'Should log the user in',
test: async () => {
await adapter.logIn(userName, password, 'clientID1')
// const newAdapterIns = new SASjs(adapter.getSasjsConfig())
const newAdapterIns = new SASjs(adapter.getSasjsConfig())
// return await newAdapterIns.checkSession()
// },
// assertion: (response: any) =>
// response?.isLoggedIn && response?.userName === userName
// },
// {
// title: 'Multiple Log in attempts',
// description:
// 'Should fail on first attempt and should log the user in on second attempt',
// test: async () => {
// await adapter.logOut()
// await adapter.logIn('invalid', 'invalid')
// return await adapter.logIn(userName, password)
// },
// assertion: (response: any) =>
// response && response.isLoggedIn && response.userName === userName
// },
return await newAdapterIns.checkSession()
},
assertion: (response: any) =>
response?.isLoggedIn && response?.userName === userName
},
{
title: 'Multiple Log in attempts',
description:
'Should fail on first attempt and should log the user in on second attempt',
test: async () => {
await adapter.logOut()
await adapter.logIn('invalid', 'invalid', 'clientID1')
return await adapter.logIn(userName, password, 'clientID1')
},
assertion: (response: any) =>
response && response.isLoggedIn && response.userName === userName
},
{
title: 'Trigger login callback',
description:
@@ -80,7 +79,7 @@ export const basicTests = (
stringData,
undefined,
async () => {
await adapter.logIn(userName, password)
await adapter.logIn(userName, password, 'clientID1')
}
)
},