-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
104 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
74 changes: 74 additions & 0 deletions
74
packages/server-core/test/unit/http/analysis-permission.spec.ts
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,74 @@ | ||
/* | ||
* Copyright (c) 2021-2024. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
import { extendObject } from '@authup/kit'; | ||
import type { AnalysisPermission } from '@privateaim/core-kit'; | ||
import { isAuthupClientUsable, useAuthupClient } from '@privateaim/server-kit'; | ||
import { | ||
createTestSuite, | ||
expectPropertiesEqualToSrc, | ||
removeDateProperties, | ||
} from '../../utils'; | ||
import { | ||
createTestNode, createTestProject, | ||
} from '../../utils/domains'; | ||
|
||
describe('src/controllers/core/analysis-permission', () => { | ||
const suite = createTestSuite(); | ||
|
||
beforeAll(async () => { | ||
await suite.up(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await suite.down(); | ||
}); | ||
|
||
const attributes : Partial<AnalysisPermission> = { | ||
permission_id: '667672f6-1c6b-468f-947f-6370cf18454c', | ||
}; | ||
|
||
it('should create resource', async () => { | ||
const client = suite.client(); | ||
|
||
const project = await client.project.create(createTestProject()); | ||
expect(project.id).toBeDefined(); | ||
|
||
const node = await client.node.create(createTestNode()); | ||
expect(node.id).toBeDefined(); | ||
|
||
// todo: maybe create authup policy | ||
if (isAuthupClientUsable()) { | ||
const authup = useAuthupClient(); | ||
|
||
const permission = await authup.permission.create({ name: 'analysis_permission' }); | ||
attributes.permission_id = permission.id; | ||
} | ||
|
||
const analysisPermission = await client.analysisPermission.create(attributes); | ||
extendObject(attributes, removeDateProperties(analysisPermission)); | ||
}); | ||
|
||
it('should read collection', async () => { | ||
const client = suite.client(); | ||
const { data } = await client.analysisPermission.getMany(); | ||
expect(data.length).toBeGreaterThanOrEqual(1); | ||
}); | ||
|
||
it('should read resource', async () => { | ||
const client = suite.client(); | ||
|
||
const data = await client.analysisPermission.getOne(attributes.id); | ||
expectPropertiesEqualToSrc(attributes, data); | ||
}); | ||
|
||
it('should delete resource', async () => { | ||
const client = suite.client(); | ||
|
||
await client.analysisPermission.delete(attributes.id); | ||
}); | ||
}); |
95 changes: 0 additions & 95 deletions
95
packages/server-core/test/unit/http/analysis-permission.ts
This file was deleted.
Oops, something went wrong.