Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI-API integration for web UI key #6387

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ export class ChefServersListComponent implements OnInit, OnDestroy {
]]
});
this.webUIKeyForm = this.fb.group({
webui_key: ['', [Validators.required,
Validators.pattern(Regex.patterns.NON_BLANK)
]]
webui_key: ['', [Validators.required]]
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,23 @@ <h2 slot="title">Add Chef Infra Server </h2>
(keyup)="handleInput($event)"
autofocus></textarea>
</label>
<chef-error class="textarea-error"
*ngIf="webUIKeyForm.get('webui_key').hasError('required') && webUIKeyForm.get('webui_key').dirty">
WEB UI KEY is required.
<chef-error
*ngIf="(webUIKeyForm.get('webui_key').hasError('required') || webUIKeyForm.get('webui_key').hasError('pattern')) && webUIKeyForm.get('webui_key').dirty">
WEB UI KEY is required.
</chef-error>
<span class="note_text">Note: A web UI Key is located <a href=''>Here</a>(Need Better Help Text).</span>
</chef-form-field>
</div>
<span class="note_text">Note: A web UI Key is located <span>Here</span>(Need Better Help Text).</span>
<div id="button-bar">
<div id="button-bar">
<chef-button id="cancel-server-popup" tertiary [disabled]="creating" (click)="closeSeverSlider()">Cancel</chef-button>
<chef-button [disabled]="!createForm?.valid || webUIKeyForm?.valid || creating || conflictError || (selected === 'fqdn') ? !fqdnForm?.valid : !ipForm?.valid"
primaryt
<chef-button
[disabled]="!createForm?.valid || !webUIKeyForm?.valid || creating || conflictError || ((selected === 'fqdn') ? !fqdnForm?.valid : !ipForm?.valid)"
primary
data-cy="add-button"
id="create-button-object-modal"
(click)="createChefServer()">
<chef-loading-spinner *ngIf="creating"></chef-loading-spinner>
<span *ngIf="!creating">Add</span>
<span *ngIf="!creating">Add Chef Infra Server</span>
<span *ngIf="creating">Adding Chef Infra Server ...</span>
</chef-button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('CreateChefServerSliderComponent', () => {
expect(createForm.valid).toBeFalsy();
expect(fqdnForm.valid).toBeFalsy();
expect(ipForm.valid).toBeFalsy();
expect(webUIKeyForm).toBeFalsy();
expect(webUIKeyForm.valid).toBeFalsy();
});

it('when name is missing', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
'organizations', orgId, 'policyGroups', policyGroup.policy_group]">{{policyGroup.policy_group}}</a>
</app-authorized>
</chef-td>
<chef-td>{{policyGroup.occurrence}}</chef-td>
<chef-td>
<app-authorized [allOf]="['/api/v0/infra/servers/{server_id}/orgs/{org_id}/policygroups/{name}', 'get', [serverId, orgId, policyGroup.policy_group]]">{{policyGroup.occurrence}}
</app-authorized>
</chef-td>
</chef-tr>
</chef-tbody>
</chef-table>
50 changes: 25 additions & 25 deletions e2e/cypress/integration/api/iam/infra_clients_actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ describe('Infra Clients get', () => {
describe('Infra Clients create', () => {
let withInfraServersClientCreateActionToken = '';
let withoutInfraServersClientCreateActionToken = '';

const cypressPrefix = 'infra-server-client-actions-create';
const policyId1 = `${cypressPrefix}-pol-1-${Cypress.moment().format('MMDDYYhhmm')}`;
const policyId2 = `${cypressPrefix}-pol-2-${Cypress.moment().format('MMDDYYhhmm')}`;
const tokenId1 = `${cypressPrefix}-token-1-${Cypress.moment().format('MMDDYYhhmm')}`;
const tokenId2 = `${cypressPrefix}-token-2-${Cypress.moment().format('MMDDYYhhmm')}`;
const objectsToCleanUp = ['tokens', 'policies'];

const withInfraServersClientCreatePolicy = {
id: policyId1,
name: tokenId1,
Expand All @@ -137,8 +137,8 @@ describe('Infra Clients create', () => {
projects: ['*']
}]
};


const withoutInfraServersClientCreatePolicy = {
id: policyId2,
name: tokenId2,
Expand All @@ -153,10 +153,10 @@ describe('Infra Clients create', () => {
projects: ['*']
}]
};

before(() => {
cy.cleanupIAMObjectsByIDPrefixes(cypressPrefix, objectsToCleanUp);

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -168,7 +168,7 @@ describe('Infra Clients create', () => {
}).then((resp) => {
withInfraServersClientCreateActionToken = resp.body.token.value;
});

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -177,7 +177,7 @@ describe('Infra Clients create', () => {
}).then((resp) => {
expect(resp.status).to.equal(200);
});

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -189,7 +189,7 @@ describe('Infra Clients create', () => {
}).then((resp) => {
withoutInfraServersClientCreateActionToken = resp.body.token.value;
});

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -199,11 +199,11 @@ describe('Infra Clients create', () => {
expect(resp.status).to.equal(200);
});
});

after(() => {
cy.cleanupIAMObjectsByIDPrefixes(cypressPrefix, objectsToCleanUp);
});

it('client post returns 200 when create actions is allowed', () => {
cy.request({
headers: { 'api-token': withInfraServersClientCreateActionToken },
Expand All @@ -215,12 +215,12 @@ describe('Infra Clients create', () => {
org_id: 'test-org',
server_id: 'local-dev',
validator: true
},
}
}).then((resp) => {
assert.equal(resp.status, 200);
});
});

it('clients post returns 403 when create actions is denied', () => {
cy.request({
headers: { 'api-token': withoutInfraServersClientCreateActionToken },
Expand All @@ -243,14 +243,14 @@ describe('Infra Clients create', () => {
describe('Infra Reset Client Key', () => {
let withInfraServersClientResetActionToken = '';
let withoutInfraServersClientResetActionToken = '';

const cypressPrefix = 'infra-server-client-actions-reset';
const policyId1 = `${cypressPrefix}-pol-1-${Cypress.moment().format('MMDDYYhhmm')}`;
const policyId2 = `${cypressPrefix}-pol-2-${Cypress.moment().format('MMDDYYhhmm')}`;
const tokenId1 = `${cypressPrefix}-token-1-${Cypress.moment().format('MMDDYYhhmm')}`;
const tokenId2 = `${cypressPrefix}-token-2-${Cypress.moment().format('MMDDYYhhmm')}`;
const objectsToCleanUp = ['tokens', 'policies'];

const withInfraServersClientResetPolicy = {
id: policyId1,
name: tokenId1,
Expand All @@ -265,8 +265,8 @@ describe('Infra Clients create', () => {
projects: ['*']
}]
};


const withoutInfraServersClientResetPolicy = {
id: policyId2,
name: tokenId2,
Expand All @@ -281,10 +281,10 @@ describe('Infra Clients create', () => {
projects: ['*']
}]
};

before(() => {
cy.cleanupIAMObjectsByIDPrefixes(cypressPrefix, objectsToCleanUp);

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -296,7 +296,7 @@ describe('Infra Clients create', () => {
}).then((resp) => {
withInfraServersClientResetActionToken = resp.body.token.value;
});

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -305,7 +305,7 @@ describe('Infra Clients create', () => {
}).then((resp) => {
expect(resp.status).to.equal(200);
});

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -317,7 +317,7 @@ describe('Infra Clients create', () => {
}).then((resp) => {
withoutInfraServersClientResetActionToken = resp.body.token.value;
});

cy.request({
headers: { 'api-token': Cypress.env('ADMIN_TOKEN') },
method: 'POST',
Expand All @@ -327,11 +327,11 @@ describe('Infra Clients create', () => {
expect(resp.status).to.equal(200);
});
});

after(() => {
cy.cleanupIAMObjectsByIDPrefixes(cypressPrefix, objectsToCleanUp);
});

it('client put returns 403 when update actions is denied', () => {
cy.request({
headers: { 'api-token': withoutInfraServersClientResetActionToken },
Expand All @@ -342,7 +342,7 @@ describe('Infra Clients create', () => {
assert.equal(resp.status, 403);
});
});

it('client put returns 200 when update actions is allowed', () => {
cy.request({
headers: { 'api-token': withInfraServersClientResetActionToken },
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/integration/api/iam/node_actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,5 @@ describe('Nodes delete', () => {
});
});


});