Merge pull request #25284 from backstage/camilaibs/more-backend-common-cleanups

[NBS 1.0] group compat files and move more files to deprecated
This commit is contained in:
Camila Belo
2024-06-18 10:29:12 +02:00
committed by GitHub
27 changed files with 23 additions and 49 deletions
+1 -1
View File
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export * from './context';
export * from './deprecated/context';
@@ -35,15 +35,14 @@ import {
createCredentialsWithUserPrincipal,
createCredentialsWithNonePrincipal,
toInternalBackstageCredentials,
} from '../../../backend-defaults/src/entrypoints/auth/helpers';
} from '../../../../backend-defaults/src/entrypoints/auth/helpers';
// TODO is this circular thingy a problem? Test in e2e
import {
type IdentityApiGetIdentityRequest,
DefaultIdentityClient,
} from '@backstage/plugin-auth-node';
import { decodeJwt } from 'jose';
import { TokenManager } from '../deprecated';
import { PluginEndpointDiscovery } from '../deprecated';
import { TokenManager, PluginEndpointDiscovery } from '../../deprecated';
import { JsonObject } from '@backstage/types';
class AuthCompat implements AuthService {
@@ -1,5 +1,5 @@
/*
* Copyright 2021 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,12 +14,7 @@
* limitations under the License.
*/
export function isValidUrl(url: string): boolean {
try {
// eslint-disable-next-line no-new
new URL(url);
return true;
} catch {
return false;
}
}
export * from './legacy';
export * from './auth';
export * from './cache';
export * from './logging';
@@ -1,5 +1,5 @@
/*
* Copyright 2021 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,21 +14,5 @@
* limitations under the License.
*/
import { isValidUrl } from './urls';
describe('isValidUrl', () => {
it('should return true for url', () => {
const validUrl = isValidUrl('http://some.valid.url');
expect(validUrl).toBe(true);
});
it('should return false for absolute path', () => {
const validUrl = isValidUrl('/some/absolute/path');
expect(validUrl).toBe(false);
});
it('should return false for relative path', () => {
const validUrl = isValidUrl('../some/relative/path');
expect(validUrl).toBe(false);
});
});
export { legacyPlugin, makeLegacyPlugin } from './legacy';
export type { LegacyCreateRouter } from './legacy';
@@ -21,12 +21,12 @@ import {
import { mockServices, startTestBackend } from '@backstage/backend-test-utils';
import { EventEmitter } from 'events';
import { Router } from 'express';
import { createLegacyAuthAdapters } from './auth';
import { createLegacyAuthAdapters } from '..';
import { legacyPlugin } from './legacy';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import { authServiceFactory } from '../../backend-app-api/src/services/implementations/auth';
import { authServiceFactory } from '../../../../backend-app-api/src/services/implementations/auth';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import { tokenManagerServiceFactory } from '../../backend-app-api/src/services/implementations/tokenManager';
import { tokenManagerServiceFactory } from '../../../../backend-app-api/src/services/implementations/tokenManager';
describe('legacyPlugin', () => {
it('can auth across the new and old systems', async () => {
@@ -21,9 +21,9 @@ import {
ServiceRef,
} from '@backstage/backend-plugin-api';
import { RequestHandler } from 'express';
import { cacheToPluginCacheManager } from './cache';
import { loggerToWinstonLogger } from './logging';
import { TokenManager } from './deprecated';
import { cacheToPluginCacheManager } from '../cache';
import { loggerToWinstonLogger } from '../logging';
import { TokenManager } from '../../deprecated';
/**
* @public
@@ -18,11 +18,11 @@
import {
createConfigSecretEnumerator,
loadBackendConfig as newLoadBackendConfig,
} from '../../backend-app-api/src/config';
} from '../../../backend-app-api/src/config';
import { LoggerService } from '@backstage/backend-plugin-api';
import { AppConfig, Config } from '@backstage/config';
import { LoadConfigOptionsRemote } from '@backstage/config-loader';
import { setRootLoggerRedactionList } from './deprecated/logging/createRootLogger';
import { setRootLoggerRedactionList } from './logging/createRootLogger';
/**
* Load configuration for a Backend.
@@ -99,6 +99,8 @@ import {
UrlReaderService as _UrlReaderService,
} from '@backstage/backend-plugin-api';
export * from './hot';
export * from './config';
export * from './scm';
export * from './tokens';
export * from './logging';
@@ -22,7 +22,7 @@ import helmet, { HelmetOptions } from 'helmet';
import { ContentSecurityPolicyOptions } from 'helmet/dist/types/middlewares/content-security-policy';
import * as http from 'http';
import { LoggerService } from '@backstage/backend-plugin-api';
import { useHotCleanup } from '../../../hot';
import { useHotCleanup } from '../../hot';
import { getRootLogger } from '../../logging';
import {
errorHandler as defaultErrorHandler,
+1 -7
View File
@@ -20,13 +20,7 @@
* @packageDocumentation
*/
export { legacyPlugin, makeLegacyPlugin } from './legacy';
export type { LegacyCreateRouter } from './legacy';
export { loadBackendConfig } from './config';
export * from './deprecated';
export * from './auth';
export * from './cache';
export * from './hot';
export * from './logging';
export * from './compat';
export * from './middleware';
export * from './service';