Skip to content

Commit

Permalink
Add permissions to dashboard serviceaccount to fetch dsci and added e…
Browse files Browse the repository at this point in the history
…xtra tests
  • Loading branch information
lucferbux authored and Gkrumbach07 committed May 10, 2024
1 parent cd10efd commit 9984ce9
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ describe('Serving Runtime List', () => {
initIntercepts({
disableModelMeshConfig: false,
disableKServeConfig: false,
disableKServeAuthConfig: true,
servingRuntimes: [],
});

Expand All @@ -619,6 +620,44 @@ describe('Serving Runtime List', () => {
kserveModal.findAuthenticationCheckbox().should('not.exist');
});

it('Kserve auth should be hidden when no required capabilities', () => {
initIntercepts({
disableModelMeshConfig: false,
disableKServeConfig: false,
disableKServeAuthConfig: false,
servingRuntimes: [],
requiredCapabilities: [],
});

projectDetails.visitSection('test-project', 'model-server');

modelServingSection.getServingPlatformCard('single-serving').findDeployModelButton().click();

kserveModal.shouldBeOpen();

// check external route, token should be checked and no alert
kserveModal.findAuthenticationCheckbox().should('not.exist');
});

it('Kserve auth should be enabled if capabilities are prsent', () => {
initIntercepts({
disableModelMeshConfig: false,
disableKServeConfig: false,
disableKServeAuthConfig: false,
servingRuntimes: [],
requiredCapabilities: [StackCapability.SERVICE_MESH, StackCapability.SERVICE_MESH_AUTHZ],
});

projectDetails.visitSection('test-project', 'model-server');

modelServingSection.getServingPlatformCard('single-serving').findDeployModelButton().click();

kserveModal.shouldBeOpen();

// check external route, token should be checked and no alert
kserveModal.findAuthenticationCheckbox().should('exist');
});

it('Do not deploy KServe model when user cannot edit namespace', () => {
initIntercepts({
disableModelMeshConfig: false,
Expand Down
69 changes: 68 additions & 1 deletion frontend/src/concepts/areas/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isAreaAvailable, SupportedArea } from '~/concepts/areas';
import { mockDscStatus } from '~/__mocks__/mockDscStatus';
import { mockDashboardConfig } from '~/__mocks__/mockDashboardConfig';
import { StackComponent } from '~/concepts/areas/types';
import { StackCapability, StackComponent } from '~/concepts/areas/types';
import { SupportedAreasStateMap } from '~/concepts/areas/const';
import { mockDsciStatus } from '~/__mocks__/mockDsciStatus';

Expand Down Expand Up @@ -188,5 +188,72 @@ describe('isAreaAvailable', () => {
expect(isAvailable.requiredComponents).toBe(null);
});
});

describe('requiredCapabilities', () => {
it('should enable area if both capabilities are enabled', () => {
// Make sure this test is valid
expect(SupportedAreasStateMap[SupportedArea.K_SERVE_AUTH].requiredCapabilities).toEqual([
StackCapability.SERVICE_MESH,
StackCapability.SERVICE_MESH_AUTHZ,
]);

// Test both reliant areas
const isAvailableKserveAuth = isAreaAvailable(
SupportedArea.K_SERVE_AUTH,
mockDashboardConfig({ disableKServeAuth: false }).spec,
mockDscStatus({
installedComponents: {
[StackComponent.K_SERVE]: true,
},
}),
mockDsciStatus({
requiredCapabilities: [
StackCapability.SERVICE_MESH,
StackCapability.SERVICE_MESH_AUTHZ,
],
}),
);

expect(isAvailableKserveAuth.status).toBe(true);
expect(isAvailableKserveAuth.featureFlags).toEqual({
disableKServeAuth: 'on',
});
expect(isAvailableKserveAuth.requiredCapabilities).toEqual({
[StackCapability.SERVICE_MESH]: true,
[StackCapability.SERVICE_MESH_AUTHZ]: true,
});
});

it('should enable area if one capability is missing', () => {
// Make sure this test is valid
expect(SupportedAreasStateMap[SupportedArea.K_SERVE_AUTH].requiredCapabilities).toEqual([
StackCapability.SERVICE_MESH,
StackCapability.SERVICE_MESH_AUTHZ,
]);

// Test both reliant areas
const isAvailableKserveAuth = isAreaAvailable(
SupportedArea.K_SERVE_AUTH,
mockDashboardConfig({ disableKServeAuth: false }).spec,
mockDscStatus({
installedComponents: {
[StackComponent.K_SERVE]: true,
},
}),
mockDsciStatus({
requiredCapabilities: [StackCapability.SERVICE_MESH],
}),
);

expect(isAvailableKserveAuth.status).toBe(false);
expect(isAvailableKserveAuth.featureFlags).toEqual({
disableKServeAuth: 'on',
});
expect(isAvailableKserveAuth.requiredCapabilities).toEqual({
[StackCapability.SERVICE_MESH]: true,
[StackCapability.SERVICE_MESH_AUTHZ]: false,
});
});
});
});
});
8 changes: 8 additions & 0 deletions manifests/base/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,11 @@ rules:
- get
resources:
- datascienceclusters
- apiGroups:
- dscinitialization.opendatahub.io
verbs:
- list
- watch
- get
resources:
- dscinitializations

0 comments on commit 9984ce9

Please sign in to comment.