Skip to content

Commit

Permalink
Fix prettier
Browse files Browse the repository at this point in the history
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
  • Loading branch information
dzemanov committed Nov 18, 2024
1 parent 4ebcff7 commit 0706751
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ export class CSVFileWatcher extends AbstractFileWatcher<string[][]> {

// Check for any old policies that will need to be removed by checking if
// the policy no longer exists in the temp enforcer (csv file)
const roleMetadatas =
await this.roleMetadataStorage.filterRoleMetadata('csv-file');
const roleMetadatas = await this.roleMetadataStorage.filterRoleMetadata(
'csv-file',
);
const fileRoles = roleMetadatas.map(meta => meta.roleEntityRef);

if (fileRoles.length > 0) {
Expand Down Expand Up @@ -180,8 +181,9 @@ export class CSVFileWatcher extends AbstractFileWatcher<string[][]> {
// temp enforcer (csv file) and a role metadata storage.
// We will update role metadata with the new source "csv-file"
private async migrateLegacyMetadata(tempEnforcer: Enforcer) {
let legacyRolesMetadata =
await this.roleMetadataStorage.filterRoleMetadata('legacy');
let legacyRolesMetadata = await this.roleMetadataStorage.filterRoleMetadata(
'legacy',
);
const legacyRoles = legacyRolesMetadata.map(meta => meta.roleEntityRef);
if (legacyRoles.length > 0) {
const legacyGroupPolicies = await tempEnforcer.getFilteredGroupingPolicy(
Expand Down Expand Up @@ -474,8 +476,9 @@ export class CSVFileWatcher extends AbstractFileWatcher<string[][]> {
isUpdate.length > 1,
);

const isRolePresent =
await this.roleMetadataStorage.findRoleMetadata(roleEntityRef);
const isRolePresent = await this.roleMetadataStorage.findRoleMetadata(
roleEntityRef,
);
const eventName = isRolePresent
? RoleEvents.UPDATE_ROLE
: RoleEvents.DELETE_ROLE;
Expand All @@ -500,8 +503,9 @@ export class CSVFileWatcher extends AbstractFileWatcher<string[][]> {
}

async cleanUpRolesAndPolicies(): Promise<void> {
const roleMetadatas =
await this.roleMetadataStorage.filterRoleMetadata('csv-file');
const roleMetadatas = await this.roleMetadataStorage.filterRoleMetadata(
'csv-file',
);
const fileRoles = roleMetadatas.map(meta => meta.roleEntityRef);

if (fileRoles.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export class LowercaseFileAdapter extends FileAdapter {
handler: (line: string, model: Model) => void,
): Promise<void> {
// Reference: https://github.com/casbin/node-casbin/blob/master/src/persist/fileAdapter.ts#L34-#L43
const bodyBuf = await (
this.fs ? this.fs : mustGetDefaultFileSystem()
const bodyBuf = await (this.fs
? this.fs
: mustGetDefaultFileSystem()
).readFileSync(this.filePath);
const lines = bodyBuf.toString().split('\n');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2279,8 +2279,12 @@ function verifyAuditLogForNonResourcedPermission(
});

const message = resourceType
? `${expectedUser ?? 'user without entity'} is ${result} for permission '${permissionName}', resource type '${resourceType}' and action '${action}'`
: `${expectedUser ?? 'user without entity'} is ${result} for permission '${permissionName}' and action '${action}'`;
? `${
expectedUser ?? 'user without entity'
} is ${result} for permission '${permissionName}', resource type '${resourceType}' and action '${action}'`
: `${
expectedUser ?? 'user without entity'
} is ${result} for permission '${permissionName}' and action '${action}'`;
expect(auditLoggerMock.auditLog).toHaveBeenNthCalledWith(2, {
actorId: expectedUser,
eventName: 'PermissionEvaluationCompleted',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ describe('Connection', () => {

await provider.applyPermissions(policies);
expect(mockLoggerService.warn).toHaveBeenCalledWith(
`Unable to add policy ${policies[0].toString()}. Cause: source does not match originating role ${policies[0][0]}, consider making changes to the 'CSV-FILE'`,
`Unable to add policy ${policies[0].toString()}. Cause: source does not match originating role ${
policies[0][0]
}, consider making changes to the 'CSV-FILE'`,
);
});

Expand Down

0 comments on commit 0706751

Please sign in to comment.