abstract tokenstore to support different storage methods of tokenstore

This commit is contained in:
2021-05-07 17:31:35 +02:00
parent ab02a49b8f
commit 0797632c44
7 changed files with 186 additions and 159 deletions

View File

@ -1,6 +1,7 @@
import React from 'react';
import AuthenticationPage from './AuthenticationPage';
import {shallow} from 'enzyme';
import {token} from "../../utils/Api";
describe('<AuthenticationPage/>', function () {
it('renders without crashing ', function () {
@ -25,8 +26,7 @@ describe('<AuthenticationPage/>', function () {
it('test fail authenticate', function () {
const events = mockKeyPress();
const helpers = require('../../utils/Api');
helpers.refreshAPIToken = jest.fn().mockImplementation((callback, force, pwd) => {
token.refreshAPIToken = jest.fn().mockImplementation((callback, force, pwd) => {
callback('there was an error')
});
@ -41,8 +41,7 @@ describe('<AuthenticationPage/>', function () {
const events = mockKeyPress();
const func = jest.fn()
const helpers = require('../../utils/Api');
helpers.refreshAPIToken = jest.fn().mockImplementation((callback, force, pwd) => {
token.refreshAPIToken = jest.fn().mockImplementation((callback, force, pwd) => {
callback('')
});

View File

@ -2,7 +2,7 @@ import React from 'react';
import {Button} from '../../elements/GPElements/Button';
import style from './AuthenticationPage.module.css';
import {addKeyHandler, removeKeyHandler} from '../../utils/ShortkeyHandler';
import {refreshAPIToken} from '../../utils/Api';
import {token} from '../../utils/Api';
import {faTimes} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
@ -76,7 +76,7 @@ class AuthenticationPage extends React.Component<Props, state> {
* request a new token and check if pwd was valid
*/
authenticate(): void {
refreshAPIToken(
token.refreshAPIToken(
(error) => {
if (error !== '') {
this.setState({wrongPWDInfo: true});