kubernetes-backend: avoid mock-fs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-09-14 11:49:35 +02:00
parent 5270b814b8
commit c8029af89c
2 changed files with 5 additions and 12 deletions
@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'buffer';
import 'buffer';
import { resolve as resolvePath } from 'path';
import { errorHandler, getVoidLogger } from '@backstage/backend-common';
import { setupRequestMockHandlers } from '@backstage/backend-test-utils';
import { NotFoundError } from '@backstage/errors';
@@ -44,7 +45,6 @@ import {
KubernetesProxy,
} from './KubernetesProxy';
import fetch from 'cross-fetch';
import mockFs from 'mock-fs';
import type { Request } from 'express';
@@ -680,15 +680,7 @@ describe('KubernetesProxy', () => {
httpsRequest.mockClear();
});
describe('should pass the exact response from Kubernetes using the CA file', () => {
afterEach(() => {
mockFs.restore();
});
it('should trust contents of specified caFile', async () => {
mockFs({
'/path/to/ca.crt': 'MOCKCA',
});
const apiResponse = {
kind: 'APIVersions',
versions: ['v1'],
@@ -706,7 +698,7 @@ describe('KubernetesProxy', () => {
url: 'https://localhost:9999',
serviceAccountToken: '',
authProvider: 'serviceAccount',
caFile: '/path/to/ca.crt',
caFile: resolvePath(__dirname, '__fixtures__/mock-ca.crt'),
},
] as ClusterDetails[]);
@@ -736,7 +728,7 @@ describe('KubernetesProxy', () => {
expect(httpsRequest).toHaveBeenCalledTimes(1);
const [[{ ca }]] = httpsRequest.mock.calls;
expect(ca).toEqual('MOCKCA');
expect(ca).toMatch('MOCKCA');
});
});
});
@@ -0,0 +1 @@
MOCKCA