-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into CHARTS-10307-add-check-parent-folder-in-rest…
…ore-entity
- Loading branch information
Showing
41 changed files
with
789 additions
and
2,354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export {ResourceType} from '../src/entities/types'; | ||
export { | ||
CollectionPermission, | ||
CollectionRole, | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../../src/tests/int/auth'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../../src/tests/int/constants'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../../src/tests/int/db'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../../src/tests/int/helpers'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../../src/tests/int/models'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../../src/tests/int/roles'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../../src/tests/int/routes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export {CollectionRole, CollectionPermission} from './collection/types'; | ||
export {WorkbookRole, WorkbookPermission} from './workbook/types'; | ||
|
||
export enum ResourceType { | ||
Collection = 'datalens.collection', | ||
Workbook = 'datalens.workbook', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const getMockedOperation = (id: string) => { | ||
const [seconds, nanoseconds] = process.hrtime(); | ||
return { | ||
createdAt: { | ||
nanos: nanoseconds, | ||
seconds: seconds.toString(), | ||
}, | ||
createdBy: '', | ||
description: 'Datalens operation', | ||
done: true, | ||
id: id, | ||
metadata: {}, | ||
modifiedAt: { | ||
nanos: nanoseconds, | ||
seconds: seconds.toString(), | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import request from 'supertest'; | ||
import { | ||
AUTHORIZATION_HEADER, | ||
DL_AUTH_HEADER_KEY, | ||
US_ERRORS, | ||
US_MASTER_TOKEN_HEADER, | ||
} from '../../const'; | ||
import {testUserId, testUserLogin} from './constants'; | ||
import {OpensourceRole} from './roles'; | ||
import usApp from '../..'; | ||
import {ZitadelUserRole} from '../../types/zitadel'; | ||
import {CollectionPermission} from '../../entities/collection/types'; | ||
import {WorkbookPermission} from '../../entities/workbook/types'; | ||
import {ResourceType} from '../../entities/types'; | ||
|
||
export {US_ERRORS}; | ||
|
||
export const app = usApp.express; | ||
export const appConfig = usApp.config; | ||
|
||
export const testTenantId = 'common'; | ||
export const testProjectId = null; | ||
|
||
export const getCollectionBinding = ( | ||
collectionId: string, | ||
permission: `${CollectionPermission}`, | ||
) => { | ||
return { | ||
id: collectionId, | ||
type: ResourceType.Collection as const, | ||
permission, | ||
}; | ||
}; | ||
|
||
export const getWorkbookBinding = (workbookId: string, permission: `${WorkbookPermission}`) => { | ||
return { | ||
id: workbookId, | ||
type: ResourceType.Workbook as const, | ||
permission, | ||
}; | ||
}; | ||
|
||
export type AccessBinding = ReturnType<typeof getCollectionBinding | typeof getWorkbookBinding>; | ||
|
||
export type AuthArgs = { | ||
userId?: string; | ||
login?: string; | ||
role?: OpensourceRole; | ||
accessBindings?: AccessBinding[]; | ||
}; | ||
|
||
export const auth = (req: request.Test, args: AuthArgs = {}) => { | ||
const { | ||
userId = testUserId, | ||
login = testUserLogin, | ||
role = OpensourceRole.Viewer, | ||
accessBindings = [], | ||
} = args; | ||
|
||
let zitadelRole: ZitadelUserRole; | ||
|
||
switch (role) { | ||
case OpensourceRole.Admin: | ||
zitadelRole = ZitadelUserRole.Admin; | ||
break; | ||
case OpensourceRole.Editor: | ||
zitadelRole = ZitadelUserRole.Editor; | ||
break; | ||
default: | ||
zitadelRole = ZitadelUserRole.Viewer; | ||
break; | ||
} | ||
|
||
req.set( | ||
AUTHORIZATION_HEADER, | ||
`${DL_AUTH_HEADER_KEY} ${JSON.stringify({ | ||
userId, | ||
login, | ||
role: zitadelRole, | ||
accessBindings, | ||
})}`, | ||
); | ||
|
||
return req; | ||
}; | ||
|
||
export const authMasterToken = (req: request.Test) => { | ||
const token = process.env.MASTER_TOKEN ?? ''; | ||
req.set(US_MASTER_TOKEN_HEADER, token); | ||
return req; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export const systemId = 'systemId'; | ||
export const systemUserId = 'systemId'; | ||
export const systemLogin = 'system'; | ||
|
||
export const testUserLogin = 'unknown'; | ||
export const testUserId = 'test-user-id'; | ||
export const testUserLogin = 'test-user-login'; | ||
|
||
export const testTenantId = 'common'; | ||
export const testProjectId = null; | ||
export const testOtherUserId = 'test-other-user-id'; | ||
|
||
export const ZITADEL_USER_ROLE_HEADER = 'zitadel-user-role'; |
Oops, something went wrong.