Skip to content

Commit 4a2069d

Browse files
committed
fixes:
1 parent 42aca67 commit 4a2069d

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

ee/packages/abac/src/clients/virtru/VirtruClient.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ describe('VirtruClient', () => {
6767
expect(tokenCalls).toHaveLength(2);
6868
});
6969

70-
it('getConfig exposes only baseUrl, defaultEntityKey and attributeNamespace', () => {
70+
it('getConfig exposes only baseUrl, defaultEntityKey, attributeNamespace and clientId', () => {
7171
const c = new VirtruClient(cfg);
7272
const pub = c.getConfig();
7373
expect(pub).toEqual({
7474
baseUrl: cfg.baseUrl,
7575
defaultEntityKey: cfg.defaultEntityKey,
7676
attributeNamespace: cfg.attributeNamespace,
77+
clientId: cfg.clientId,
7778
});
78-
expect(pub).not.toHaveProperty('clientId');
7979
expect(pub).not.toHaveProperty('clientSecret');
8080
expect(pub).not.toHaveProperty('oidcEndpoint');
8181
});

ee/packages/abac/src/clients/virtru/VirtruClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const virtruClientLogger = logger.section('VirtruClient');
88
export const HEALTH_CHECK_TIMEOUT = 5000;
99
const REQUEST_TIMEOUT = 10000;
1010

11-
type PublicVirtruConfig = Pick<IVirtruPDPConfig, 'baseUrl' | 'defaultEntityKey' | 'attributeNamespace'>;
11+
type PublicVirtruConfig = Pick<IVirtruPDPConfig, 'baseUrl' | 'defaultEntityKey' | 'attributeNamespace' | 'clientId'>;
1212

1313
export class VirtruClient {
1414
private tokenCache: ITokenCache | null = null;
@@ -25,8 +25,8 @@ export class VirtruClient {
2525
}
2626

2727
getConfig(): PublicVirtruConfig {
28-
const { baseUrl, defaultEntityKey, attributeNamespace } = this.config;
29-
return { baseUrl, defaultEntityKey, attributeNamespace };
28+
const { baseUrl, defaultEntityKey, attributeNamespace, clientId } = this.config;
29+
return { baseUrl, defaultEntityKey, attributeNamespace, clientId };
3030
}
3131

3232
async isAvailable(): Promise<boolean> {

ee/packages/abac/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,15 @@ export class AbacService extends ServiceClass implements IAbacService {
535535
const room = await getAbacRoom(rid);
536536
const store = await this.resolveAttributeStore();
537537

538-
await store.assertCanModifyRoom(room, actor);
539-
540538
if (!Object.keys(attributes).length && room.abacAttributes?.length) {
541539
await Rooms.unsetAbacAttributesById(rid);
542540
void Audit.objectAttributesRemoved({ _id: room._id, name: room.name }, room.abacAttributes, actor);
543541
this.broadcastRoomUpdate({ ...room, abacAttributes: undefined });
544542
return;
545543
}
546544

545+
await store.assertCanModifyRoom(room, actor);
546+
547547
const normalized = validateAndNormalizeAttributes(attributes);
548548

549549
await store.validateAssignable(normalized, actor);

ee/packages/abac/src/service.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,15 +1110,16 @@ describe('AbacService (unit)', () => {
11101110
});
11111111
});
11121112

1113-
it('blocks the empty-clear path of setRoomAbacAttributes when assertCanModifyRoom rejects', async () => {
1113+
it('skips assertCanModifyRoom on the empty-clear path of setRoomAbacAttributes and still unsets', async () => {
11141114
const store = makeStore();
11151115
store.assertCanModifyRoom.mockRejectedValueOnce(new Error('error-pdp-unavailable'));
11161116
(service as any).attributeStores.local.store = store;
11171117

1118-
await expect(service.setRoomAbacAttributes('r1', {}, fakeActor)).rejects.toThrow('error-pdp-unavailable');
1118+
await expect(service.setRoomAbacAttributes('r1', {}, fakeActor)).resolves.toBeUndefined();
11191119

1120-
expect(mockUnsetAbacAttributesById).not.toHaveBeenCalled();
1121-
expect(mockCreateAuditServerEvent).not.toHaveBeenCalled();
1120+
expect(store.assertCanModifyRoom).not.toHaveBeenCalled();
1121+
expect(store.validateAssignable).not.toHaveBeenCalled();
1122+
expect(mockUnsetAbacAttributesById).toHaveBeenCalledWith('r1');
11221123
});
11231124
});
11241125

0 commit comments

Comments
 (0)