-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(root): include local tunnel work (#5698)
* feat: include local tunnel work Add local tunnel script to novu app Add storage of local tunnel url * feat: include local tunnel work Add test for user registration case in enterprise * feat: include local tunnel work Consolidate scripts to one source * feat: include local tunnel work Update modules to be typescript instead of javascript Update output package json command Update build command to clean dist before building * feat: include local tunnel work Update formatting Add tunnel interface to conform to * feat: include local tunnel work Adjust per PR comments and discussion * feat: include local tunnel work Subdomain calculated from ApiKey on launch instead on scaffold Run script with tsx * feat: include local tunnel work Adjust how concurrently handles tasks Adjust text in output * feat: include local tunnel work Regenerate echo url on api key rotation * feat: include local tunnel work Remove unused package * feat: include local tunnel work Update lock file * feat: include local tunnel work Update lock file * feat: include local tunnel work Update lock file * feat: include local tunnel work Update lock file * feat: include local tunnel work PR suggestions * feat: include local tunnel work Update restart cooldown to be 1sec * feat: include local tunnel work Add error handler logic that enables restart on tunnel fail * feat: include local tunnel work update ee package reference
- Loading branch information
1 parent
50de962
commit 612b0d9
Showing
21 changed files
with
410 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { EnvironmentRepository } from '@novu/dal'; | ||
import { UserSession } from '@novu/testing'; | ||
import * as jwt from 'jsonwebtoken'; | ||
import { expect } from 'chai'; | ||
import { IJwtPayload } from '@novu/shared'; | ||
|
||
describe('User registration in enterprise - /auth/register (POST)', async () => { | ||
let session: UserSession; | ||
const environmentRepository = new EnvironmentRepository(); | ||
|
||
before(async () => { | ||
session = new UserSession(); | ||
await session.initialize(); | ||
}); | ||
|
||
it('registered user should have the bridge url set on their environment', async () => { | ||
const { body } = await session.testAgent.post('/v1/auth/register').send({ | ||
email: 'Testy.test-org@gmail.com', | ||
firstName: 'Test', | ||
lastName: 'User', | ||
password: '123@Qwerty', | ||
organizationName: 'Sample org', | ||
}); | ||
|
||
expect(body.data.token).to.be.ok; | ||
|
||
const jwtContent = (await jwt.decode(body.data.token)) as IJwtPayload; | ||
|
||
expect(jwtContent.environmentId).to.be.ok; | ||
const environment = await environmentRepository.findOne({ _id: jwtContent.environmentId }); | ||
|
||
expect(environment.echo.url).to.be.ok; | ||
}); | ||
}); |
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
32 changes: 32 additions & 0 deletions
32
apps/api/src/app/environments/e2e/regenerate-api-keys.e2e-ee.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,32 @@ | ||
import { UserSession } from '@novu/testing'; | ||
import { expect } from 'chai'; | ||
import { UpdateEnvironmentRequestDto } from '../dtos/update-environment-request.dto'; | ||
|
||
describe('Environment - Regenerate Api Key', async () => { | ||
let session: UserSession; | ||
|
||
before(async () => { | ||
session = new UserSession(); | ||
await session.initialize(); | ||
}); | ||
|
||
it('should regenerate echo url on api key regeneration as well', async () => { | ||
const updatePayload: UpdateEnvironmentRequestDto = { | ||
name: 'Development', | ||
bridge: { url: 'http://example.com' }, | ||
}; | ||
|
||
await session.testAgent.put(`/v1/environments/${session.environment._id}`).send(updatePayload).expect(200); | ||
|
||
const firstResponse = await session.testAgent.get('/v1/environments/me'); | ||
|
||
const oldEchoUrl = firstResponse.body.data.echo.url; | ||
|
||
await session.testAgent.post('/v1/environments/api-keys/regenerate').send({}); | ||
const secondResponse = await session.testAgent.get('/v1/environments/me'); | ||
|
||
const updatedEchoUrl = secondResponse.body.data.echo.url; | ||
|
||
expect(updatedEchoUrl).to.not.equal(oldEchoUrl); | ||
}); | ||
}); |
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
25 changes: 25 additions & 0 deletions
25
apps/api/src/app/environments/usecases/update-environment/update-environment.e2e-ee.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,25 @@ | ||
import { UserSession } from '@novu/testing'; | ||
import { expect } from 'chai'; | ||
import { UpdateEnvironmentRequestDto } from '../../dtos/update-environment-request.dto'; | ||
|
||
describe('Update Environment - /environments (PUT)', async () => { | ||
let session: UserSession; | ||
|
||
before(async () => { | ||
session = new UserSession(); | ||
await session.initialize(); | ||
}); | ||
|
||
it('should update bridge data correctly', async () => { | ||
const updatePayload: UpdateEnvironmentRequestDto = { | ||
name: 'Development', | ||
bridge: { url: 'http://example.com' }, | ||
}; | ||
|
||
await session.testAgent.put(`/v1/environments/${session.environment._id}`).send(updatePayload).expect(200); | ||
const { body } = await session.testAgent.get('/v1/environments/me'); | ||
|
||
expect(body.data.name).to.eq(updatePayload.name); | ||
expect(body.data.echo.url).to.equal(updatePayload.bridge?.url); | ||
}); | ||
}); |
1 change: 0 additions & 1 deletion
1
apps/api/src/app/environments/usecases/update-environment/update-environment.e2e.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
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
22 changes: 22 additions & 0 deletions
22
libs/application-generic/src/utils/buildBridgeEndpointUrl.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,22 @@ | ||
import { createHash } from 'crypto'; | ||
|
||
/* | ||
* Creates a bridge endpoint url to be used for request from novu cloud to the local | ||
* workflow definition | ||
*/ | ||
export const buildBridgeEndpointUrl = ( | ||
apiKey: string, | ||
baseAddress: string | ||
): string => { | ||
return `${buildBridgeSubdomain(apiKey)}.${baseAddress}`; | ||
}; | ||
|
||
/* | ||
* Creates a bridge subdomain based on the apiKey provided. This function is used in several | ||
* places, including packages/create-novu-app/templates/index.ts when generating the | ||
* subdomain in the bridge application. Developers should take care to keep changes | ||
* in sync. | ||
*/ | ||
export const buildBridgeSubdomain = (apiKey: string): string => { | ||
return createHash('md5').update(apiKey).digest('hex'); | ||
}; |
Oops, something went wrong.