1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-18 01:20:05 +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( const handleSubmit = useCallback(
(e) => { (e) => {
e.preventDefault() e.preventDefault()
appContext.adapter.logIn(username, password).then((res) => { appContext.adapter.logIn(username, password, 'clientID1').then((res) => {
appContext.setIsLoggedIn(res.isLoggedIn) appContext.setIsLoggedIn(res.isLoggedIn)
}) })
}, },

View File

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