Skip to content

Commit

Permalink
fix(rbac): move permission-policy.ts to policies directory
Browse files Browse the repository at this point in the history
  • Loading branch information
PatAKnight committed Oct 21, 2024
1 parent 67e48b9 commit 6b40de8
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {
RoleMetadataDao,
RoleMetadataStorage,
} from '../database/role-metadata';
import { ADMIN_ROLE_AUTHOR } from '../policies/permission-policy';
import { BackstageRoleManager } from '../role-manager/role-manager';
import { EnforcerDelegate } from '../service/enforcer-delegate';
import { MODEL } from '../service/permission-model';
import { ADMIN_ROLE_AUTHOR } from '../service/permission-policy';
import { CSVFileWatcher } from './csv-file-watcher';

const legacyPermission = [
Expand Down
2 changes: 1 addition & 1 deletion plugins/rbac-backend/src/helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
typedPoliciesToString,
typedPolicyToString,
} from './helper';
import { ADMIN_ROLE_AUTHOR } from './policies/permission-policy';
// Import the function to test
import { EnforcerDelegate } from './service/enforcer-delegate';
import { ADMIN_ROLE_AUTHOR } from './service/permission-policy';

const modifiedBy = 'user:default/some-user';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ import {
RoleMetadataDao,
RoleMetadataStorage,
} from '../database/role-metadata';
import {
ADMIN_ROLE_NAME,
RBACPermissionPolicy,
} from '../policies/permission-policy';
import { BackstageRoleManager } from '../role-manager/role-manager';
import { EnforcerDelegate } from './enforcer-delegate';
import { MODEL } from './permission-model';
import { ADMIN_ROLE_NAME, RBACPermissionPolicy } from './permission-policy';
import { PluginPermissionMetadataCollector } from './plugin-endpoints';
import { EnforcerDelegate } from '../service/enforcer-delegate';
import { MODEL } from '../service/permission-model';
import { PluginPermissionMetadataCollector } from '../service/plugin-endpoints';

type PermissionAction = 'create' | 'read' | 'update' | 'delete';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ import {
import { CSVFileWatcher } from '../file-permissions/csv-file-watcher';
import { YamlConditinalPoliciesFileWatcher } from '../file-permissions/yaml-conditional-file-watcher';
import { removeTheDifference } from '../helper';
import { EnforcerDelegate } from '../service/enforcer-delegate';
import { PluginPermissionMetadataCollector } from '../service/plugin-endpoints';
import { validateEntityReference } from '../validation/policies-validation';
import { EnforcerDelegate } from './enforcer-delegate';
import { PluginPermissionMetadataCollector } from './plugin-endpoints';

export const ADMIN_ROLE_NAME = 'role:default/rbac_admin';
export const ADMIN_ROLE_AUTHOR = 'application configuration';
Expand Down
2 changes: 1 addition & 1 deletion plugins/rbac-backend/src/service/enforcer-delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
RoleMetadataStorage,
} from '../database/role-metadata';
import { mergeRoleMetadata, policiesToString, policyToString } from '../helper';
import { ADMIN_ROLE_NAME } from '../policies/permission-policy';
import { MODEL } from './permission-model';
import { ADMIN_ROLE_NAME } from './permission-policy';

export type RoleEvents = 'roleAdded';
export interface RoleEventEmitter<T extends RoleEvents> {
Expand Down
2 changes: 1 addition & 1 deletion plugins/rbac-backend/src/service/policies-rest-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
RoleMetadataDao,
RoleMetadataStorage,
} from '../database/role-metadata';
import { RBACPermissionPolicy } from '../policies/permission-policy';
import { EnforcerDelegate } from './enforcer-delegate';
import { RBACPermissionPolicy } from './permission-policy';
import {
PluginMetadataResponseSerializedRule,
PluginPermissionMetadataCollector,
Expand Down
4 changes: 2 additions & 2 deletions plugins/rbac-backend/src/service/policy-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
} from '@janus-idp/backstage-plugin-rbac-node';

import { CasbinDBAdapterFactory } from '../database/casbin-adapter-factory';
import { RBACPermissionPolicy } from './permission-policy';
import { RBACPermissionPolicy } from '../policies/permission-policy';
import { PluginPermissionMetadataCollector } from './plugin-endpoints';
import { PoliciesServer } from './policies-rest-api';
import { PolicyBuilder } from './policy-builder';
Expand Down Expand Up @@ -78,7 +78,7 @@ jest.mock('./policies-rest-api', () => {
};
});

jest.mock('./permission-policy', () => {
jest.mock('../policies/permission-policy', () => {
return {
RBACPermissionPolicy: {
build: jest.fn((): Promise<RBACPermissionPolicy> => {
Expand Down
2 changes: 1 addition & 1 deletion plugins/rbac-backend/src/service/policy-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import { DataBaseConditionalStorage } from '../database/conditional-storage';
import { migrate } from '../database/migration';
import { DataBaseRoleMetadataStorage } from '../database/role-metadata';
import { AllowAllPolicy } from '../policies/allow-all-policy';
import { RBACPermissionPolicy } from '../policies/permission-policy';
import { connectRBACProviders } from '../providers/connect-providers';
import { BackstageRoleManager } from '../role-manager/role-manager';
import { EnforcerDelegate } from './enforcer-delegate';
import { MODEL } from './permission-model';
import { RBACPermissionPolicy } from './permission-policy';
import { PluginPermissionMetadataCollector } from './plugin-endpoints';
import { PoliciesServer } from './policies-rest-api';

Expand Down

0 comments on commit 6b40de8

Please sign in to comment.