-
Notifications
You must be signed in to change notification settings - Fork 4
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
100 additions
and
0 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
70 changes: 70 additions & 0 deletions
70
packages/backend/jobs-manager/service/src/modules/findings/findings.e2e-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,70 @@ | ||
import { INestApplication, ValidationPipe } from '@nestjs/common'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { | ||
TestingData, | ||
checkAuthorizations, | ||
checkAuthorizationsCronApiKey, | ||
getReq, | ||
initTesting, | ||
postReq, | ||
} from '../../test/e2e.utils'; | ||
import { AppModule } from '../app.module'; | ||
import { Role } from '../auth/constants'; | ||
|
||
describe('Findings Controller (e2e)', () => { | ||
let app: INestApplication; | ||
let testData: TestingData; | ||
let jobId: string; | ||
|
||
beforeAll(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
app.useGlobalPipes( | ||
new ValidationPipe({ | ||
whitelist: true, | ||
forbidNonWhitelisted: true, | ||
}), | ||
); | ||
await app.init(); | ||
testData = await initTesting(app); | ||
}); | ||
|
||
afterAll(async () => { | ||
await app.close(); | ||
}); | ||
|
||
// #################################### | ||
// ########## Authorizations ########## | ||
// #################################### | ||
|
||
it('Should have proper authorizations (GET /findings/)', async () => { | ||
const success = await checkAuthorizations( | ||
testData, | ||
Role.ReadOnly, | ||
async (givenToken: string) => { | ||
return await getReq(app, givenToken, `/findings/`); | ||
}, | ||
); | ||
expect(success).toBe(true); | ||
}); | ||
|
||
it('Should have proper authorizations (POST /findings/cleanup)', async () => { | ||
const success = await checkAuthorizationsCronApiKey( | ||
testData, | ||
async (givenToken: string, headers, authenticate) => { | ||
return await postReq( | ||
app, | ||
givenToken, | ||
`/findings/cleanup`, | ||
undefined, | ||
headers, | ||
authenticate, | ||
); | ||
}, | ||
); | ||
expect(success).toBe(true); | ||
}); | ||
}); |
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