-
Notifications
You must be signed in to change notification settings - Fork 3
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
5 changed files
with
61 additions
and
25 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
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,28 @@ | ||
const cds = require('@sap/cds') | ||
|
||
const { POST } = cds.test().in(__dirname) | ||
const log = cds.test.log() | ||
|
||
cds.env.requires['audit-log'].credentials = process.env.ALS_CREDS_PREMIUM && JSON.parse(process.env.ALS_CREDS_PREMIUM) | ||
|
||
// stay in provider account (i.e., use "$PROVIDER" and avoid x-zid header when fetching oauth2 token) | ||
cds.env.requires.auth.users.alice.tenant = cds.env.requires['audit-log'].credentials.uaa.tenantid | ||
|
||
cds.env.log.levels['audit-log'] = 'debug' | ||
|
||
describe('Log to Audit Log Service with premium plan', () => { | ||
if (!cds.env.requires['audit-log'].credentials) | ||
return test.skip('Skipping tests due to missing credentials', () => {}) | ||
|
||
// required for tests to exit correctly (cf. token expiration timeouts) | ||
jest.useFakeTimers() | ||
|
||
require('./tests')(POST) | ||
|
||
test('no tenant is handled correctly', async () => { | ||
const data = JSON.stringify({ data: { foo: 'bar' } }) | ||
const res = await POST('/integration/passthrough', { event: 'SecurityEvent', data }) | ||
expect(res).toMatchObject({ status: 204 }) | ||
expect(log.output.match(/\$PROVIDER/)).toBeTruthy() | ||
}) | ||
}) |