@backstage/backend-test-utils 0.5.0 → 0.6.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -2
- package/dist/index.cjs.js +27 -76
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +32 -31
- package/package.json +10 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="jest" />
|
|
3
|
+
/// <reference types="qs" />
|
|
4
|
+
/// <reference types="express" />
|
|
3
5
|
import Keyv from 'keyv';
|
|
4
6
|
import { Knex } from 'knex';
|
|
5
7
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
6
|
-
import { ServiceFactory, ServiceRef, ExtensionPoint, BackendFeature, RootConfigService, LoggerService,
|
|
8
|
+
import { ServiceFactory, ServiceRef, ExtensionPoint, BackendFeature, RootConfigService, LoggerService, AuthService, DiscoveryService, BackstageCredentials, HttpAuthService, BackstageUserInfo, UserInfoService, BackstageNonePrincipal, BackstageUserPrincipal, BackstagePrincipalAccessRestrictions, BackstageServicePrincipal } from '@backstage/backend-plugin-api';
|
|
7
9
|
import { Backend } from '@backstage/backend-app-api';
|
|
8
10
|
import * as _backstage_backend_defaults_rootHttpRouter from '@backstage/backend-defaults/rootHttpRouter';
|
|
9
11
|
import { ExtendedHttpServer } from '@backstage/backend-defaults/rootHttpRouter';
|
|
10
12
|
import * as _backstage_plugin_events_node from '@backstage/plugin-events-node';
|
|
11
13
|
import { JsonObject } from '@backstage/types';
|
|
14
|
+
import * as express from 'express';
|
|
15
|
+
import * as qs from 'qs';
|
|
16
|
+
import * as express_serve_static_core from 'express-serve-static-core';
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
19
|
* The possible caches to test against.
|
|
@@ -405,37 +410,27 @@ declare namespace mockServices {
|
|
|
405
410
|
type Options = {
|
|
406
411
|
data?: JsonObject;
|
|
407
412
|
};
|
|
408
|
-
const factory:
|
|
413
|
+
const factory: (options?: Options | undefined) => ServiceFactory<RootConfigService, "root", "singleton" | "multiton">;
|
|
409
414
|
}
|
|
410
415
|
function rootLogger(options?: rootLogger.Options): LoggerService;
|
|
411
416
|
namespace rootLogger {
|
|
412
417
|
type Options = {
|
|
413
418
|
level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
414
419
|
};
|
|
415
|
-
const factory:
|
|
420
|
+
const factory: (options?: Options | undefined) => ServiceFactory<LoggerService, "root", "singleton" | "multiton">;
|
|
416
421
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootLoggerService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootLoggerService>;
|
|
417
422
|
}
|
|
418
|
-
function tokenManager(): TokenManagerService;
|
|
419
|
-
namespace tokenManager {
|
|
420
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<TokenManagerService, "plugin", "singleton", undefined>;
|
|
421
|
-
const mock: (partialImpl?: Partial<TokenManagerService> | undefined) => ServiceMock<TokenManagerService>;
|
|
422
|
-
}
|
|
423
|
-
function identity(): IdentityService;
|
|
424
|
-
namespace identity {
|
|
425
|
-
const factory: _backstage_backend_plugin_api.ServiceFactoryCompat<IdentityService, "plugin", "singleton", undefined>;
|
|
426
|
-
const mock: (partialImpl?: Partial<IdentityService> | undefined) => ServiceMock<IdentityService>;
|
|
427
|
-
}
|
|
428
423
|
function auth(options?: {
|
|
429
424
|
pluginId?: string;
|
|
430
425
|
disableDefaultAuthPolicy?: boolean;
|
|
431
426
|
}): AuthService;
|
|
432
427
|
namespace auth {
|
|
433
|
-
const factory:
|
|
428
|
+
const factory: () => ServiceFactory<AuthService, "plugin", "singleton">;
|
|
434
429
|
const mock: (partialImpl?: Partial<AuthService> | undefined) => ServiceMock<AuthService>;
|
|
435
430
|
}
|
|
436
431
|
function discovery(): DiscoveryService;
|
|
437
432
|
namespace discovery {
|
|
438
|
-
const factory:
|
|
433
|
+
const factory: () => ServiceFactory<DiscoveryService, "plugin", "singleton">;
|
|
439
434
|
const mock: (partialImpl?: Partial<DiscoveryService> | undefined) => ServiceMock<DiscoveryService>;
|
|
440
435
|
}
|
|
441
436
|
/**
|
|
@@ -464,9 +459,9 @@ declare namespace mockServices {
|
|
|
464
459
|
* the default mock user principal. This behavior can be configured with the
|
|
465
460
|
* `defaultCredentials` option.
|
|
466
461
|
*/
|
|
467
|
-
const factory: (
|
|
462
|
+
const factory: (options?: {
|
|
468
463
|
defaultCredentials?: BackstageCredentials;
|
|
469
|
-
}) => ServiceFactory<HttpAuthService, "plugin", "singleton"
|
|
464
|
+
}) => ServiceFactory<HttpAuthService, "plugin", "singleton">;
|
|
470
465
|
const mock: (partialImpl?: Partial<HttpAuthService> | undefined) => ServiceMock<HttpAuthService>;
|
|
471
466
|
}
|
|
472
467
|
/**
|
|
@@ -484,55 +479,55 @@ declare namespace mockServices {
|
|
|
484
479
|
* By default it extracts the user's entity ref from a user principal and
|
|
485
480
|
* returns that as the only ownership entity ref.
|
|
486
481
|
*/
|
|
487
|
-
const factory:
|
|
482
|
+
const factory: () => ServiceFactory<UserInfoService, "plugin", "singleton">;
|
|
488
483
|
const mock: (partialImpl?: Partial<UserInfoService> | undefined) => ServiceMock<UserInfoService>;
|
|
489
484
|
}
|
|
490
485
|
namespace cache {
|
|
491
|
-
const factory:
|
|
486
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.CacheService, "plugin", "singleton">;
|
|
492
487
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.CacheService> | undefined) => ServiceMock<_backstage_backend_plugin_api.CacheService>;
|
|
493
488
|
}
|
|
494
489
|
namespace database {
|
|
495
|
-
const factory:
|
|
490
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.DatabaseService, "plugin", "singleton">;
|
|
496
491
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.DatabaseService> | undefined) => ServiceMock<_backstage_backend_plugin_api.DatabaseService>;
|
|
497
492
|
}
|
|
498
493
|
namespace rootHealth {
|
|
499
|
-
const factory:
|
|
494
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.RootHealthService, "root", "singleton">;
|
|
500
495
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootHealthService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootHealthService>;
|
|
501
496
|
}
|
|
502
497
|
namespace httpRouter {
|
|
503
|
-
const factory:
|
|
498
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.HttpRouterService, "plugin", "singleton">;
|
|
504
499
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.HttpRouterService> | undefined) => ServiceMock<_backstage_backend_plugin_api.HttpRouterService>;
|
|
505
500
|
}
|
|
506
501
|
namespace rootHttpRouter {
|
|
507
|
-
const factory: ((options?: _backstage_backend_defaults_rootHttpRouter.RootHttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root", "singleton">) & ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root", "singleton">;
|
|
502
|
+
const factory: () => ((options?: _backstage_backend_defaults_rootHttpRouter.RootHttpRouterFactoryOptions | undefined) => ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root", "singleton">) & ServiceFactory<_backstage_backend_plugin_api.RootHttpRouterService, "root", "singleton">;
|
|
508
503
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootHttpRouterService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootHttpRouterService>;
|
|
509
504
|
}
|
|
510
505
|
namespace lifecycle {
|
|
511
|
-
const factory:
|
|
506
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.LifecycleService, "plugin", "singleton">;
|
|
512
507
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.LifecycleService> | undefined) => ServiceMock<_backstage_backend_plugin_api.LifecycleService>;
|
|
513
508
|
}
|
|
514
509
|
namespace logger {
|
|
515
|
-
const factory:
|
|
510
|
+
const factory: () => ServiceFactory<LoggerService, "plugin", "singleton">;
|
|
516
511
|
const mock: (partialImpl?: Partial<LoggerService> | undefined) => ServiceMock<LoggerService>;
|
|
517
512
|
}
|
|
518
513
|
namespace permissions {
|
|
519
|
-
const factory:
|
|
514
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.PermissionsService, "plugin", "singleton">;
|
|
520
515
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.PermissionsService> | undefined) => ServiceMock<_backstage_backend_plugin_api.PermissionsService>;
|
|
521
516
|
}
|
|
522
517
|
namespace rootLifecycle {
|
|
523
|
-
const factory:
|
|
518
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.RootLifecycleService, "root", "singleton">;
|
|
524
519
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.RootLifecycleService> | undefined) => ServiceMock<_backstage_backend_plugin_api.RootLifecycleService>;
|
|
525
520
|
}
|
|
526
521
|
namespace scheduler {
|
|
527
|
-
const factory:
|
|
522
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.SchedulerService, "plugin", "singleton">;
|
|
528
523
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.SchedulerService> | undefined) => ServiceMock<_backstage_backend_plugin_api.SchedulerService>;
|
|
529
524
|
}
|
|
530
525
|
namespace urlReader {
|
|
531
|
-
const factory:
|
|
526
|
+
const factory: () => ServiceFactory<_backstage_backend_plugin_api.UrlReaderService, "plugin", "singleton">;
|
|
532
527
|
const mock: (partialImpl?: Partial<_backstage_backend_plugin_api.UrlReaderService> | undefined) => ServiceMock<_backstage_backend_plugin_api.UrlReaderService>;
|
|
533
528
|
}
|
|
534
529
|
namespace events {
|
|
535
|
-
const factory:
|
|
530
|
+
const factory: () => ServiceFactory<_backstage_plugin_events_node.EventsService, "plugin", "singleton">;
|
|
536
531
|
const mock: (partialImpl?: Partial<_backstage_plugin_events_node.EventsService> | undefined) => ServiceMock<_backstage_plugin_events_node.EventsService>;
|
|
537
532
|
}
|
|
538
533
|
}
|
|
@@ -644,4 +639,10 @@ declare namespace mockCredentials {
|
|
|
644
639
|
}
|
|
645
640
|
}
|
|
646
641
|
|
|
647
|
-
|
|
642
|
+
/**
|
|
643
|
+
* A mock for error handler middleware that can be used in router tests.
|
|
644
|
+
* @public
|
|
645
|
+
*/
|
|
646
|
+
declare function mockErrorHandler(): express.ErrorRequestHandler<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>;
|
|
647
|
+
|
|
648
|
+
export { type CreateMockDirectoryOptions, type MockDirectory, type MockDirectoryContent, type MockDirectoryContentCallback, type MockDirectoryContentCallbackContext, type MockDirectoryContentOptions, ServiceFactoryTester, type ServiceFactoryTesterOptions, type ServiceMock, type TestBackend, type TestBackendOptions, type TestCacheId, TestCaches, type TestDatabaseId, TestDatabases, createMockDirectory, mockCredentials, mockErrorHandler, mockServices, registerMswTestHooks, startTestBackend };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-test-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-next.0",
|
|
4
4
|
"description": "Test helpers library for Backstage backends",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -42,17 +42,20 @@
|
|
|
42
42
|
"test": "backstage-cli package test"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@backstage/backend-app-api": "^0.
|
|
46
|
-
"@backstage/backend-defaults": "^0.
|
|
47
|
-
"@backstage/backend-plugin-api": "^0.
|
|
45
|
+
"@backstage/backend-app-api": "^0.10.0-next.0",
|
|
46
|
+
"@backstage/backend-defaults": "^0.5.0-next.0",
|
|
47
|
+
"@backstage/backend-plugin-api": "^0.9.0-next.0",
|
|
48
48
|
"@backstage/config": "^1.2.0",
|
|
49
49
|
"@backstage/errors": "^1.2.4",
|
|
50
|
-
"@backstage/plugin-auth-node": "^0.5.0",
|
|
51
|
-
"@backstage/plugin-events-node": "^0.
|
|
50
|
+
"@backstage/plugin-auth-node": "^0.5.2-next.0",
|
|
51
|
+
"@backstage/plugin-events-node": "^0.4.0-next.0",
|
|
52
52
|
"@backstage/types": "^1.1.1",
|
|
53
53
|
"@keyv/memcache": "^1.3.5",
|
|
54
54
|
"@keyv/redis": "^2.5.3",
|
|
55
|
+
"@types/express": "^4.17.6",
|
|
56
|
+
"@types/express-serve-static-core": "^4.17.5",
|
|
55
57
|
"@types/keyv": "^4.2.0",
|
|
58
|
+
"@types/qs": "^6.9.6",
|
|
56
59
|
"better-sqlite3": "^11.0.0",
|
|
57
60
|
"cookie": "^0.6.0",
|
|
58
61
|
"express": "^4.17.1",
|
|
@@ -69,7 +72,7 @@
|
|
|
69
72
|
"yn": "^4.0.0"
|
|
70
73
|
},
|
|
71
74
|
"devDependencies": {
|
|
72
|
-
"@backstage/cli": "^0.27.0",
|
|
75
|
+
"@backstage/cli": "^0.27.1-next.0",
|
|
73
76
|
"@types/supertest": "^2.0.8",
|
|
74
77
|
"supertest": "^6.1.3"
|
|
75
78
|
},
|