mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
Merge pull request #1260 from hedgedoc/renovate/develop-prettier-2.x
This commit is contained in:
commit
15e51f1244
11 changed files with 99 additions and 93 deletions
|
@ -77,7 +77,7 @@
|
|||
"eslint-config-prettier": "8.3.0",
|
||||
"eslint-plugin-import": "2.23.2",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"prettier": "2.3.0",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.6",
|
||||
"ts-loader": "9.1.2",
|
||||
|
|
|
@ -33,9 +33,9 @@ export class TokensController {
|
|||
@Get()
|
||||
async getUserTokens(): Promise<AuthTokenDto[]> {
|
||||
// ToDo: Get real userName
|
||||
return (
|
||||
await this.authService.getTokensByUsername('hardcoded')
|
||||
).map((token) => this.authService.toAuthTokenDto(token));
|
||||
return (await this.authService.getTokensByUsername('hardcoded')).map(
|
||||
(token) => this.authService.toAuthTokenDto(token),
|
||||
);
|
||||
}
|
||||
|
||||
@Post()
|
||||
|
|
|
@ -159,7 +159,9 @@ describe('AuthService', () => {
|
|||
user: user,
|
||||
lastUsed: new Date(1549312452000),
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'save').mockImplementationOnce(
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'save')
|
||||
.mockImplementationOnce(
|
||||
async (authTokenSaved, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.keyId).toEqual(authToken.keyId);
|
||||
expect(authTokenSaved.lastUsed).not.toEqual(1549312452000);
|
||||
|
@ -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,7 +251,9 @@ describe('AuthService', () => {
|
|||
...user,
|
||||
authTokens: [authToken],
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'save').mockImplementationOnce(
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'save')
|
||||
.mockImplementationOnce(
|
||||
async (authTokenSaved: AuthToken, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.lastUsed).toBeNull();
|
||||
return authTokenSaved;
|
||||
|
@ -273,7 +277,9 @@ describe('AuthService', () => {
|
|||
...user,
|
||||
authTokens: [authToken],
|
||||
});
|
||||
jest.spyOn(authTokenRepo, 'save').mockImplementationOnce(
|
||||
jest
|
||||
.spyOn(authTokenRepo, 'save')
|
||||
.mockImplementationOnce(
|
||||
async (authTokenSaved: AuthToken, _): Promise<AuthToken> => {
|
||||
expect(authTokenSaved.lastUsed).toBeNull();
|
||||
return authTokenSaved;
|
||||
|
|
|
@ -229,20 +229,18 @@ const authSchema = Joi.object({
|
|||
|
||||
export default registerAs('authConfig', () => {
|
||||
// ToDo: Validate these with Joi to prevent duplicate entries?
|
||||
const gitlabNames = toArrayConfig(
|
||||
process.env.HD_AUTH_GITLABS,
|
||||
',',
|
||||
).map((name) => name.toUpperCase());
|
||||
const gitlabNames = toArrayConfig(process.env.HD_AUTH_GITLABS, ',').map(
|
||||
(name) => name.toUpperCase(),
|
||||
);
|
||||
const ldapNames = toArrayConfig(process.env.HD_AUTH_LDAPS, ',').map((name) =>
|
||||
name.toUpperCase(),
|
||||
);
|
||||
const samlNames = toArrayConfig(process.env.HD_AUTH_SAMLS, ',').map((name) =>
|
||||
name.toUpperCase(),
|
||||
);
|
||||
const oauth2Names = toArrayConfig(
|
||||
process.env.HD_AUTH_OAUTH2S,
|
||||
',',
|
||||
).map((name) => name.toUpperCase());
|
||||
const oauth2Names = toArrayConfig(process.env.HD_AUTH_OAUTH2S, ',').map(
|
||||
(name) => name.toUpperCase(),
|
||||
);
|
||||
|
||||
const gitlabs = gitlabNames.map((gitlabName) => {
|
||||
return {
|
||||
|
|
|
@ -210,12 +210,13 @@ describe('FrontendConfigService', () => {
|
|||
imprint: imprintLink,
|
||||
},
|
||||
};
|
||||
const externalServicesConfig: ExternalServicesConfig = {
|
||||
const externalServicesConfig: ExternalServicesConfig =
|
||||
{
|
||||
plantUmlServer: plantUmlServer,
|
||||
imageProxy: imageProxy,
|
||||
};
|
||||
const module: TestingModule = await Test.createTestingModule(
|
||||
{
|
||||
const module: TestingModule =
|
||||
await Test.createTestingModule({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
|
@ -238,8 +239,7 @@ describe('FrontendConfigService', () => {
|
|||
LoggerModule,
|
||||
],
|
||||
providers: [FrontendConfigService],
|
||||
},
|
||||
).compile();
|
||||
}).compile();
|
||||
|
||||
const service = module.get(FrontendConfigService);
|
||||
const config = await service.getFrontendConfig();
|
||||
|
|
|
@ -250,7 +250,9 @@ describe('HistoryService', () => {
|
|||
const historyEntry = HistoryEntry.create(user, note);
|
||||
it('with an entry', async () => {
|
||||
jest.spyOn(historyRepo, 'find').mockResolvedValueOnce([historyEntry]);
|
||||
jest.spyOn(historyRepo, 'remove').mockImplementationOnce(
|
||||
jest
|
||||
.spyOn(historyRepo, 'remove')
|
||||
.mockImplementationOnce(
|
||||
async (entry: HistoryEntry): Promise<HistoryEntry> => {
|
||||
expect(entry).toEqual(historyEntry);
|
||||
return entry;
|
||||
|
@ -298,7 +300,9 @@ describe('HistoryService', () => {
|
|||
const historyEntry = HistoryEntry.create(user, note);
|
||||
jest.spyOn(historyRepo, 'findOne').mockResolvedValueOnce(historyEntry);
|
||||
jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note);
|
||||
jest.spyOn(historyRepo, 'remove').mockImplementation(
|
||||
jest
|
||||
.spyOn(historyRepo, 'remove')
|
||||
.mockImplementation(
|
||||
async (entry: HistoryEntry): Promise<HistoryEntry> => {
|
||||
expect(entry).toEqual(historyEntry);
|
||||
return entry;
|
||||
|
|
|
@ -42,9 +42,8 @@ export class AzureBackend implements MediaBackend {
|
|||
buffer: Buffer,
|
||||
fileName: string,
|
||||
): Promise<[string, BackendData]> {
|
||||
const blockBlobClient: BlockBlobClient = this.client.getBlockBlobClient(
|
||||
fileName,
|
||||
);
|
||||
const blockBlobClient: BlockBlobClient =
|
||||
this.client.getBlockBlobClient(fileName);
|
||||
try {
|
||||
await blockBlobClient.upload(buffer, buffer.length);
|
||||
const url = this.getUrl(fileName);
|
||||
|
@ -61,9 +60,8 @@ export class AzureBackend implements MediaBackend {
|
|||
}
|
||||
|
||||
async deleteFile(fileName: string, _: BackendData): Promise<void> {
|
||||
const blockBlobClient: BlockBlobClient = this.client.getBlockBlobClient(
|
||||
fileName,
|
||||
);
|
||||
const blockBlobClient: BlockBlobClient =
|
||||
this.client.getBlockBlobClient(fileName);
|
||||
try {
|
||||
await blockBlobClient.delete();
|
||||
const url = this.getUrl(fileName);
|
||||
|
|
|
@ -112,7 +112,9 @@ describe('MediaService', () => {
|
|||
fileId = entry.id;
|
||||
return entry;
|
||||
});
|
||||
jest.spyOn(service.mediaBackend, 'saveFile').mockImplementationOnce(
|
||||
jest
|
||||
.spyOn(service.mediaBackend, 'saveFile')
|
||||
.mockImplementationOnce(
|
||||
async (
|
||||
buffer: Buffer,
|
||||
fileName: string,
|
||||
|
@ -150,7 +152,9 @@ describe('MediaService', () => {
|
|||
userName: 'hardcoded',
|
||||
} as User,
|
||||
} as MediaUpload;
|
||||
jest.spyOn(service.mediaBackend, 'deleteFile').mockImplementationOnce(
|
||||
jest
|
||||
.spyOn(service.mediaBackend, 'deleteFile')
|
||||
.mockImplementationOnce(
|
||||
async (fileName: string, backendData: BackendData): Promise<void> => {
|
||||
expect(fileName).toEqual(mockMediaUploadEntry.id);
|
||||
expect(backendData).toEqual(mockMediaUploadEntry.backendData);
|
||||
|
|
|
@ -462,9 +462,8 @@ describe('PermissionsService', () => {
|
|||
|
||||
describe('check if groups work with', () => {
|
||||
const guestPermission = GuestPermission.WRITE;
|
||||
const rawPermissions = createNoteGroupPermissionsCombinations(
|
||||
guestPermission,
|
||||
);
|
||||
const rawPermissions =
|
||||
createNoteGroupPermissionsCombinations(guestPermission);
|
||||
const permissions = permuteNoteGroupPermissions(rawPermissions);
|
||||
let i = 0;
|
||||
for (const permission of permissions) {
|
||||
|
|
|
@ -122,18 +122,15 @@ describe('Me', () => {
|
|||
it('works with an existing note', async () => {
|
||||
const noteName = 'testGetNoteHistory2';
|
||||
const note = await notesService.createNote('', noteName);
|
||||
const createdHistoryEntry = await historyService.createOrUpdateHistoryEntry(
|
||||
note,
|
||||
user,
|
||||
);
|
||||
const createdHistoryEntry =
|
||||
await historyService.createOrUpdateHistoryEntry(note, user);
|
||||
const response = await request(app.getHttpServer())
|
||||
.get(`/me/history/${noteName}`)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200);
|
||||
const historyEntry = <HistoryEntryDto>response.body;
|
||||
const historyEntryDto = historyService.toHistoryEntryDto(
|
||||
createdHistoryEntry,
|
||||
);
|
||||
const historyEntryDto =
|
||||
historyService.toHistoryEntryDto(createdHistoryEntry);
|
||||
expect(historyEntry.identifier).toEqual(historyEntryDto.identifier);
|
||||
expect(historyEntry.title).toEqual(historyEntryDto.title);
|
||||
expect(historyEntry.tags).toEqual(historyEntryDto.tags);
|
||||
|
|
|
@ -5837,10 +5837,10 @@ prelude-ls@~1.1.2:
|
|||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
|
||||
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
|
||||
|
||||
prettier@2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
|
||||
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
|
||||
prettier@2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.0.tgz#b6a5bf1284026ae640f17f7ff5658a7567fc0d18"
|
||||
integrity sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==
|
||||
|
||||
pretty-format@^26.0.0, pretty-format@^26.6.2:
|
||||
version "26.6.2"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue