proxy-backend: add test for deprecated configuration
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
"yup": "^0.32.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/backend-test-utils": "workspace:^",
|
||||
"@backstage/cli": "workspace:^",
|
||||
"@backstage/config-loader": "workspace:^",
|
||||
"@types/http-proxy-middleware": "^0.19.3",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { getVoidLogger, SingleHostDiscovery } from '@backstage/backend-common';
|
||||
import { mockServices } from '@backstage/backend-test-utils';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { Request, Response } from 'express';
|
||||
import * as http from 'http';
|
||||
@@ -70,6 +71,32 @@ describe('createRouter', () => {
|
||||
expect(router).toBeDefined();
|
||||
});
|
||||
|
||||
it('supports deprecated proxy configuration', async () => {
|
||||
const router = await createRouter({
|
||||
config: mockServices.rootConfig({
|
||||
data: {
|
||||
proxy: {
|
||||
'/test': {
|
||||
target: 'https://example.com',
|
||||
headers: {
|
||||
Authorization: 'Bearer supersecret',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
logger,
|
||||
discovery,
|
||||
});
|
||||
expect(router).toBeDefined();
|
||||
expect(mockCreateProxyMiddleware).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
expect.objectContaining({
|
||||
target: 'https://example.com',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('revives request bodies when set', async () => {
|
||||
const router = await createRouter({
|
||||
config,
|
||||
|
||||
@@ -8053,6 +8053,7 @@ __metadata:
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/backend-test-utils": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/config": "workspace:^"
|
||||
"@backstage/config-loader": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user