permission-backend: replace cross-fetch with node-fetch

Signed-off-by: Mike Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
Mike Lewis
2021-11-25 09:50:24 +00:00
parent 7a8312f126
commit 2e5a67b77d
3 changed files with 6 additions and 6 deletions
@@ -162,7 +162,7 @@ describe('PermissionIntegrationClient', () => {
resourceType: 'test-resource',
conditions: mockConditions,
}),
).rejects.toThrowError(/request failed with 401/i);
).rejects.toThrowError(/401/i);
});
it('should reject invalid responses', async () => {
@@ -14,9 +14,8 @@
* limitations under the License.
*/
import fetch from 'cross-fetch';
import fetch from 'node-fetch';
import { z } from 'zod';
import { ResponseError } from '@backstage/errors';
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import {
AuthorizeResult,
@@ -73,7 +72,9 @@ export class PermissionIntegrationClient {
});
if (!response.ok) {
throw await ResponseError.fromResponse(response);
throw new Error(
`Unexpected response from plugin upstream when applying conditions. Expected 200 but got ${response.status} - ${response.statusText}`,
);
}
return responseSchema.parse(await response.json());