proxy-backend: add test for deprecated configuration

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-08-02 16:52:28 +02:00
parent 24450b8a40
commit 76a710edd9
3 changed files with 29 additions and 0 deletions
+1
View File
@@ -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,
+1
View File
@@ -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:^"