-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(amplify-provider-awscloudformation): specify 127.0.0.1 as hostname (
#6780) * fix(amplify-provider-awscloudformation): specify 0.0.0.0 as hostname for adminui login server to force listening on ipv4 instead of ipv6 when available.
- Loading branch information
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/amplify-provider-awscloudformation/src/__tests__/utils/admin-login-server.test.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,44 @@ | ||
import { AdminLoginServer } from '../../utils/admin-login-server'; | ||
import { $TSContext } from 'amplify-cli-core'; | ||
import { FunctionRuntimeLifecycleManager } from 'amplify-function-plugin-interface'; | ||
|
||
const runtimePlugin_stub = ({ | ||
checkDependencies: jest.fn().mockResolvedValue({ hasRequiredDependencies: true }), | ||
build: jest.fn().mockResolvedValue({ rebuilt: true }), | ||
} as unknown) as jest.Mocked<FunctionRuntimeLifecycleManager>; | ||
|
||
const context_stub = ({ | ||
amplify: { | ||
readBreadcrumbs: jest.fn().mockReturnValue({ pluginId: 'testPluginId' }), | ||
loadRuntimePlugin: jest.fn().mockResolvedValue(runtimePlugin_stub), | ||
updateamplifyMetaAfterBuild: jest.fn(), | ||
}, | ||
} as unknown) as jest.Mocked<$TSContext>; | ||
|
||
const useMock = jest.fn(); | ||
const postMock = jest.fn(async () => {}); | ||
const listenMock = jest.fn(); | ||
|
||
jest.mock('express', () => { | ||
return () => { | ||
return { | ||
use: useMock, | ||
post: postMock, | ||
listen: listenMock, | ||
}; | ||
}; | ||
}); | ||
|
||
describe('AdminLoginServer', () => { | ||
test('run server with 0.0.0.0', async () => { | ||
const adminLoginServer = new AdminLoginServer('appId', 'http://example.com', context_stub.print); | ||
|
||
await new Promise<void>(resolve => { | ||
adminLoginServer.startServer(() => {}); | ||
resolve(); | ||
}); | ||
expect(useMock).toBeCalled(); | ||
expect(postMock).toBeCalled(); | ||
expect(listenMock).toBeCalledWith(4242, '0.0.0.0'); | ||
}); | ||
}); |
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