-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: rbac config [TESTENG-108] (#10032)
Co-authored-by: John Kim <[email protected]>
- Loading branch information
1 parent
6c8b42b
commit 43fccb8
Showing
10 changed files
with
192 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
temp_dir: /tmp/priority_scheduler | ||
|
||
stages: | ||
- db: | ||
name: db | ||
|
||
- master: | ||
pre: | ||
- sh: make -C tools prep-root | ||
config_file: | ||
security: | ||
initial_user_password: $INITIAL_USER_PASSWORD | ||
authz: | ||
rbac_ui_enabled: true | ||
port: 8082 | ||
db: | ||
host: localhost | ||
port: 5432 | ||
password: postgres | ||
user: postgres | ||
name: determined | ||
checkpoint_storage: | ||
type: shared_fs | ||
host_path: /tmp | ||
storage_path: determined-cp | ||
log: | ||
level: debug | ||
root: tools/build | ||
cache: | ||
cache_dir: /tmp/determined-cache | ||
launch_error: false | ||
telemetry: | ||
enabled: false | ||
resource_manager: | ||
default_aux_resource_pool: default | ||
default_compute_resource_pool: default | ||
type: agent | ||
|
||
- agent: | ||
name: agent1 | ||
config_file: | ||
master_host: 127.0.0.1 | ||
master_port: 8082 | ||
agent_id: agent1 | ||
container_master_host: $DOCKER_LOCALHOST | ||
agent_reconnect_attempts: 24 | ||
agent_reconnect_backoff: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import streamConsumers from 'stream/consumers'; | ||
|
||
import _ from 'lodash'; | ||
|
||
import { RBACApi, V1AssignRolesRequest, V1AssignRolesResponse } from 'services/api-ts-sdk/api'; | ||
|
||
import { ApiAuthFixture } from './api.auth.fixture'; | ||
|
||
export class ApiRoleFixture { | ||
readonly apiAuth: ApiAuthFixture; | ||
constructor(apiAuth: ApiAuthFixture) { | ||
this.apiAuth = apiAuth; | ||
} | ||
|
||
new({ roleProps = {} } = {}): V1AssignRolesRequest { | ||
const defaults = {}; | ||
return { | ||
...defaults, | ||
...roleProps, | ||
}; | ||
} | ||
|
||
private static normalizeUrl(url: string): string { | ||
if (url.endsWith('/')) { | ||
return url.substring(0, url.length - 1); | ||
} | ||
return url; | ||
} | ||
|
||
private async startRoleRequest(): Promise<RBACApi> { | ||
return new RBACApi( | ||
{ apiKey: await this.apiAuth.getBearerToken() }, | ||
ApiRoleFixture.normalizeUrl(this.apiAuth.baseURL), | ||
fetch, | ||
); | ||
} | ||
|
||
async createAssignment(req: V1AssignRolesRequest): Promise<V1AssignRolesResponse> { | ||
const roleResp = await (await this.startRoleRequest()) | ||
.assignRoles(req, {}) | ||
.catch(async function (error) { | ||
const respBody = await streamConsumers.text(error.body); | ||
throw new Error( | ||
`Create Assignment Failed: ${error.status} Request: ${JSON.stringify( | ||
req, | ||
)} Response: ${respBody}`, | ||
); | ||
}); | ||
return _.merge(req, roleResp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { DeterminedPage } from 'e2e/models/common/base/BasePage'; | ||
import { isRbacEnabled } from 'e2e/utils/rbac'; | ||
|
||
/** | ||
* Represents the DefaultRoute page from src/pages/DefaultRoute.tsx | ||
*/ | ||
export class DefaultRoute extends DeterminedPage { | ||
// only redirects to Dashboard or WorkspaceList page | ||
readonly title = isRbacEnabled() ? 'Workspaces' : 'Home'; | ||
readonly url = isRbacEnabled() ? /workspaces/ : /dashboard/; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { detExecSync } from 'e2e/utils/detCLI'; | ||
|
||
let rbacEnabled: boolean; | ||
|
||
const getRbacEnabled = (): boolean => { | ||
const masterInfo = detExecSync('master info'); | ||
const regexp = /rbacEnabled:\s*(?<enabled>true|false)/; | ||
|
||
const { groups } = regexp.exec(masterInfo) || {}; | ||
|
||
return groups?.enabled === 'true'; | ||
}; | ||
|
||
export const isRbacEnabled = (): boolean => { | ||
if (rbacEnabled === undefined) rbacEnabled = getRbacEnabled(); | ||
|
||
return rbacEnabled; | ||
}; |