mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
fix: remove usage of Role.UPC
This commit is contained in:
@@ -22,7 +22,7 @@ describe('AuthService', () => {
|
|||||||
id: '10f356da-1e9e-43b8-9028-a26a645539a6',
|
id: '10f356da-1e9e-43b8-9028-a26a645539a6',
|
||||||
name: 'Test API Key',
|
name: 'Test API Key',
|
||||||
description: 'Test API Key Description',
|
description: 'Test API Key Description',
|
||||||
roles: [Role.GUEST, Role.UPC],
|
roles: [Role.GUEST, Role.CONNECT],
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ describe('AuthService', () => {
|
|||||||
id: '-1',
|
id: '-1',
|
||||||
description: 'Test User',
|
description: 'Test User',
|
||||||
name: 'test_user',
|
name: 'test_user',
|
||||||
roles: [Role.GUEST, Role.UPC],
|
roles: [Role.GUEST, Role.CONNECT],
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -134,13 +134,13 @@ describe('AuthService', () => {
|
|||||||
|
|
||||||
const mockApiKeyWithoutRole = {
|
const mockApiKeyWithoutRole = {
|
||||||
...mockApiKey,
|
...mockApiKey,
|
||||||
roles: [Role.UPC],
|
roles: [Role.ADMIN],
|
||||||
};
|
};
|
||||||
|
|
||||||
vi.spyOn(apiKeyService, 'findById').mockResolvedValue(mockApiKeyWithoutRole);
|
vi.spyOn(apiKeyService, 'findById').mockResolvedValue(mockApiKeyWithoutRole);
|
||||||
vi.spyOn(apiKeyService, 'findByIdWithSecret').mockResolvedValue({
|
vi.spyOn(apiKeyService, 'findByIdWithSecret').mockResolvedValue({
|
||||||
...mockApiKeyWithSecret,
|
...mockApiKeyWithSecret,
|
||||||
roles: [Role.UPC],
|
roles: [Role.ADMIN],
|
||||||
});
|
});
|
||||||
vi.spyOn(apiKeyService, 'saveApiKey').mockResolvedValue();
|
vi.spyOn(apiKeyService, 'saveApiKey').mockResolvedValue();
|
||||||
vi.spyOn(authzService, 'addRoleForUser').mockResolvedValue(true);
|
vi.spyOn(authzService, 'addRoleForUser').mockResolvedValue(true);
|
||||||
@@ -152,7 +152,7 @@ describe('AuthService', () => {
|
|||||||
expect(apiKeyService.findByIdWithSecret).toHaveBeenCalledWith(apiKeyId);
|
expect(apiKeyService.findByIdWithSecret).toHaveBeenCalledWith(apiKeyId);
|
||||||
expect(apiKeyService.saveApiKey).toHaveBeenCalledWith({
|
expect(apiKeyService.saveApiKey).toHaveBeenCalledWith({
|
||||||
...mockApiKeyWithSecret,
|
...mockApiKeyWithSecret,
|
||||||
roles: [Role.UPC, role],
|
roles: [Role.ADMIN, role],
|
||||||
});
|
});
|
||||||
expect(authzService.addRoleForUser).toHaveBeenCalledWith(apiKeyId, role);
|
expect(authzService.addRoleForUser).toHaveBeenCalledWith(apiKeyId, role);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -220,9 +220,9 @@ export class AuthService {
|
|||||||
this.logger.debug('getSessionUser called!');
|
this.logger.debug('getSessionUser called!');
|
||||||
return {
|
return {
|
||||||
id: '-1',
|
id: '-1',
|
||||||
description: 'UPC service account',
|
description: 'Session receives administrator permissions',
|
||||||
name: 'upc',
|
name: 'admin',
|
||||||
roles: [Role.UPC],
|
roles: [Role.ADMIN],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user