mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 18:55:19 -04:00
Format with Prettier 2.3
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
6658f0d5b4
commit
eaf1852fe5
9 changed files with 94 additions and 88 deletions
|
@ -159,13 +159,15 @@ describe('AuthService', () => {
|
|||
user: user,
|
||||
lastUsed: new Date(1549312452000),
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'save').mockImplementationOnce(
|
||||
async (authTokenSaved, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.keyId).toEqual(authToken.keyId);
|
||||
expect(authTokenSaved.lastUsed).not.toEqual(1549312452000);
|
||||
return authToken;
|
||||
},
|
||||
);
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'save')
|
||||
.mockImplementationOnce(
|
||||
async (authTokenSaved, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.keyId).toEqual(authToken.keyId);
|
||||
expect(authTokenSaved.lastUsed).not.toEqual(1549312452000);
|
||||
return authToken;
|
||||
},
|
||||
);
|
||||
await service.setLastUsedToken(authToken.keyId);
|
||||
});
|
||||
it('throws if the token is not in the database', async () => {
|
||||
|
@ -189,11 +191,11 @@ describe('AuthService', () => {
|
|||
user: user,
|
||||
accessTokenHash: accessTokenHash,
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'save').mockImplementationOnce(
|
||||
async (_, __): Promise<AuthToken> => {
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'save')
|
||||
.mockImplementationOnce(async (_, __): Promise<AuthToken> => {
|
||||
return authToken;
|
||||
},
|
||||
);
|
||||
});
|
||||
const userByToken = await service.validateToken(
|
||||
`${authToken.keyId}.${token}`,
|
||||
);
|
||||
|
@ -222,15 +224,15 @@ describe('AuthService', () => {
|
|||
...authToken,
|
||||
user: user,
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'remove').mockImplementationOnce(
|
||||
async (token, __): Promise<AuthToken> => {
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'remove')
|
||||
.mockImplementationOnce(async (token, __): Promise<AuthToken> => {
|
||||
expect(token).toEqual({
|
||||
...authToken,
|
||||
user: user,
|
||||
});
|
||||
return authToken;
|
||||
},
|
||||
);
|
||||
});
|
||||
await service.removeToken(authToken.keyId);
|
||||
});
|
||||
it('throws if the token is not in the database', async () => {
|
||||
|
@ -249,12 +251,14 @@ describe('AuthService', () => {
|
|||
...user,
|
||||
authTokens: [authToken],
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'save').mockImplementationOnce(
|
||||
async (authTokenSaved: AuthToken, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.lastUsed).toBeNull();
|
||||
return authTokenSaved;
|
||||
},
|
||||
);
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'save')
|
||||
.mockImplementationOnce(
|
||||
async (authTokenSaved: AuthToken, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.lastUsed).toBeNull();
|
||||
return authTokenSaved;
|
||||
},
|
||||
);
|
||||
const token = await service.createTokenForUser(
|
||||
user.userName,
|
||||
identifier,
|
||||
|
@ -273,12 +277,14 @@ describe('AuthService', () => {
|
|||
...user,
|
||||
authTokens: [authToken],
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'save').mockImplementationOnce(
|
||||
async (authTokenSaved: AuthToken, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.lastUsed).toBeNull();
|
||||
return authTokenSaved;
|
||||
},
|
||||
);
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'save')
|
||||
.mockImplementationOnce(
|
||||
async (authTokenSaved: AuthToken, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.lastUsed).toBeNull();
|
||||
return authTokenSaved;
|
||||
},
|
||||
);
|
||||
const validUntil = new Date().getTime() + 30000;
|
||||
const token = await service.createTokenForUser(
|
||||
user.userName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue