Skip to content

Commit

Permalink
5.0.2 release (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
melil02 authored Jun 9, 2021
1 parent f2dc941 commit e77d6fd
Show file tree
Hide file tree
Showing 37 changed files with 1,674 additions and 422 deletions.
139 changes: 128 additions & 11 deletions cypress/integration/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ describe('Applications', () => {
'Self-enabling global workforce'
);

cy.findByText('JSON Chief Directives').click();

cy.findByLabelText('API Key / Client ID').should(
'contain',
'b43b8e38-511a-4234-b533-4264a8fcaa26'
'l7286a421be91244e79a43faf333fbdd14'
);

cy.findByLabelText('Shared Secret / Client Secret').should(
'contain',
'cf4f15ea-b8c5-453c-8072-9b5115db5eb9'
'********'
);

cy.findByLabelText('Callback/Redirect URL(s)').should(
Expand All @@ -78,10 +80,10 @@ describe('Applications', () => {

cy.findByLabelText('Scope').should('contain', 'OOB');

cy.findByLabelText('Type').should('contain', 'confidential');
cy.findByLabelText('Type').should('contain', 'public');
});

it.skip('should show generate secret ', () => {
it('should NOT show Generate New Secret when Application status is APPLICATION_PENDING_APPROVAL for an org user', () => {
login('orgPublisher', 'Password@1');

cy.findAllByText('Applications')
Expand All @@ -90,14 +92,107 @@ describe('Applications', () => {

cy.findByTitle('Display as list').click();

cy.findByTitle('CSS Human Intranet').click({ force: true });
cy.findByTitle('GB Future Response').click({ force: true });

cy.findByText('Edit').click();
// Details
cy.findByLabelText('Generate New Secret').should('not.exist');
});

cy.findByLabelText('Generate New Secret').should('exist');
context('when editing an application', () => {
it('should allow the changing of an API plan on a selected API', () => {
cy.loadData();
login('orgAdmin', 'Password@1');
cy.findAllByText('Applications')
.first()
.click();

cy.findByTitle('Display as list').click();
cy.findByTitle('CSS Human Intranet').click({ force: true });

// Ignore any errors in the console
cy.on('uncaught:exception', (err, runnable) => {
cy.findByText('Edit').click({ force: true });

// Click the first selected API from the selector widget to open the accordion
cy.findByText('SMTP Chief Accounts').click({ force: true });

// Click to edit the API plan
cy.findByText('API Plan: API Plan 1');
cy.findByTitle('Edit').click({ force: true });

// Choose a different API plan from the modal
cy.findByText('Select an API Plan (Required)');
cy.findByText('API Plan 3').click({ force: true });

// Accept the terms and conditions of the new API plan
cy.findByText('Lorem ipsum dolor sit amet');
cy.findByText('I Accept the Terms & Conditions').click({
force: true,
});

// The first API plan should be replaced with the new one chosen
cy.findByText('API Plan: API Plan 3');
return false;
});
});

it('should show the API key as the default key', () => {
cy.loadData();
login('orgAdmin', 'Password@1');
cy.findAllByText('Applications')
.first()
.click();

cy.findByTitle('Display as list').click();
cy.findByTitle('CSS Human Intranet').click({ force: true });

// Ignore any errors in the console
cy.on('uncaught:exception', (err, runnable) => {
cy.findByText('Edit').click({ force: true });

// Click the first selected API from the selector widget to open the accordion
cy.findByText('SMTP Chief Accounts').click({ force: true });

// Click to edit the API plan
cy.findByText('API Plan: API Plan 1');
cy.findByTitle('Edit').click({ force: true });

expect(
cy.findByText('API Key / Client ID').next().innerHTML
).toEqual('Default');

return false;
});
});

it('should display a progress dialog when deleting', () => {
cy.loadData();
login('orgAdmin', 'Password@1');
cy.findAllByText('Applications')
.first()
.click();

cy.findByTitle('Display as list').click();
cy.findByTitle('ADP Dynamic Integration').click({ force: true });
cy.on('uncaught:exception', (err, runnable) => {
cy.findByText('Delete').click({ force: true });

cy.findByText(
'You are about to delete this application. Are you sure?'
);

cy.findByText('Delete').click({ force: true });

cy.findByText(
'Undeploying keys and deleting application. This may take several minutes.'
);

return false;
});
});
});

it('should NOT show Generate New Secret when Application status is APPLICATION_PENDING_APPROVAL for an org user', () => {
it.skip('should show generate secret ', () => {
login('orgPublisher', 'Password@1');

cy.findAllByText('Applications')
Expand All @@ -106,10 +201,11 @@ describe('Applications', () => {

cy.findByTitle('Display as list').click();

cy.findByTitle('GB Future Response').click({ force: true });
cy.findByTitle('CSS Human Intranet').click({ force: true });

// Details
cy.findByLabelText('Generate New Secret').should('not.exist');
cy.findByText('Edit').click();

cy.findByLabelText('Generate New Secret').should('exist');
});

it.skip('should show Generate New Secret when Application status is APPLICATION_PENDING_APPROVAL for a portal admin', () => {
Expand All @@ -126,4 +222,25 @@ describe('Applications', () => {
// Details
cy.findByLabelText('Generate New Secret').should('exist');
});

it.skip('should change the page size', () => {
login('portalAdmin', 'Password@1');

cy.findAllByText('Applications')
.first()
.click();

cy.get('p.MuiTablePagination-caption').should(
'have.text',
'Items per page:1-12 of 25'
);
cy.get('div.MuiTablePagination-input')
.first()
.click({ force: true });
cy.findByText('24').click({ force: true });
cy.get('p.MuiTablePagination-caption').should(
'have.text',
'Items per page:1-24 of 25'
);
});
});
2 changes: 1 addition & 1 deletion packages/example/src/layout/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const AppBar = ({
<HideOnScroll>
<MuiAppBar
className={className}
color="#FFFFFF"
color="default"
elevation={2}
{...rest}
>
Expand Down
3 changes: 1 addition & 2 deletions packages/example/src/layout/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { HomePageContent } from 'layer7-apihub';
import { makeStyles } from '@material-ui/core/styles';

import { ContentLogo, Footer } from '../ui';
import { Footer } from '../ui';

export const HomePage = () => {
const classes = useStyles();
Expand All @@ -11,7 +11,6 @@ export const HomePage = () => {
<>
<div className={classes.root}>
<HomePageContent className={classes.markdown} />
<ContentLogo className={classes.logo} />
</div>
<Footer />
</>
Expand Down
45 changes: 45 additions & 0 deletions packages/layer7-apihub-mock/src/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function generateData() {
const apis = generateApis({ tags, apiEulas });
const apiGroups = generateApiGroups({ apis });
const applications = generateApplications({ apis });
const apiKeys = generateApiKeys({ applications });
const documents = [
...generateDocumentationForApis({ apis }),
...generateDocumentationForWiki(),
Expand Down Expand Up @@ -319,6 +320,49 @@ function generateApplication({ apis, ...data }) {
);
}

function generateApiKeys({ applications }) {
return Array.from(Array(25).keys()).map((el) =>
generateApiKey({ applicationUuid: applications[0].uuid, el })
);
}

function generateApiKey({ applicationUuid, el, ...data }) {
const uuid = faker.random.uuid();

const apiKey = faker.random.uuid();
const keySecret = faker.random.uuid();
const defaultKey = (el === 0);
const status = defaultKey ? 'ENABLED' : faker.random.arrayElement([
'ENABLED',
'ENABLED',
'ENABLED',
'ENABLED',
'DISABLED',
'DISABLED',
]);

return merge(
{
id: uuid,
apiKey,
name: faker.fake(
'{{hacker.abbreviation}} {{name.jobDescriptor}} {{name.jobArea}}'
),
keySecret,
applicationUuid,
defaultKey,
status,
keySecretHashed: false,
oauthCallbackUrl: 'https://example.com/oauthCallback',
oauthScope: 'OOB',
oauthType: faker.random.arrayElement(['public', 'confidential']),
createTs: Date.now(),
modifyTs: Date.now(),
},
data
);
}

function generateTags() {
return [
{ uuid: faker.random.uuid(), name: 'Accounts' },
Expand Down Expand Up @@ -536,5 +580,6 @@ module.exports = {
generateApis,
generateApiGroups,
generateApplications,
generateApiKeys,
generateRegistrations,
};
33 changes: 29 additions & 4 deletions packages/layer7-apihub-mock/src/defaultData.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
{
"uuid": "dd010ee0-4cb0-4388-9a95-4a216c0ea8c3",
"name": "SMTP Chief Accounts",
"status": "DEPRECATED"
"status": "ENABLED"
},
{
"uuid": "9170b2d3-1d8d-4ad6-ac6e-f471a9297dae",
Expand Down Expand Up @@ -354,7 +354,7 @@
"modifyTs": 1592887894715,
"version": "5.7.8",
"ssgServiceType": "SOAP",
"portalStatus": "DEPRECATED",
"portalStatus": "ENABLED",
"accessStatus": "PUBLIC",
"apiEulaUuid": "c9406345-eb76-11e3-b0cd-000nosaj86a8",
"applicationUsage": 1,
Expand Down Expand Up @@ -490,7 +490,7 @@
"modifyTs": 1592897689575,
"version": "3.1.4",
"ssgServiceType": "REST",
"portalStatus": "DEPRECATED",
"portalStatus": "ENABLED",
"accessStatus": "PUBLIC",
"apiEulaUuid": "c9406345-eb76-11e3-b0cd-000nosaj86a8",
"applicationUsage": 2,
Expand Down Expand Up @@ -541,7 +541,7 @@
"modifyTs": 1592862643594,
"version": "8.1.2",
"ssgServiceType": "SOAP",
"portalStatus": "DISABLED",
"portalStatus": "ENABLED",
"accessStatus": "PRIVATE",
"apiEulaUuid": "c9406345-eb76-11e3-b0cd-000nosaj86a8",
"applicationUsage": 6,
Expand Down Expand Up @@ -713,6 +713,13 @@
"8a334a2f-de19-472a-bb11-5a6e38e1c2ee"
]
},
"apiApiPlanIds": {
"results": [
{ "ApiUuid": "dd010ee0-4cb0-4388-9a95-4a216c0ea8c3", "ApiPlanUuid": "791cc920-2147-4125-91ae-955206a043b5" },
{ "ApiUuid": "df9c715b-cff5-4d7a-a8cf-eefe382040d0", "ApiPlanUuid": "8910fe1f-34df-4451-b053-7101a314e8b3" },
{ "ApiUuid": "8a334a2f-de19-472a-bb11-5a6e38e1c2ee", "ApiPlanUuid": "d9d300dd-931e-4b74-82a4-85a44242f89b" }
]
},
"_accessibleApis": [
"dd010ee0-4cb0-4388-9a95-4a216c0ea8c3",
"df9c715b-cff5-4d7a-a8cf-eefe382040d0"
Expand Down Expand Up @@ -1188,6 +1195,24 @@
]
}
],
"apiKeys": [
{
"id": "a27767e6-2000-49c2-80ae-6bd6cb8e2873",
"apiKey": "l7286a421be91244e79a43faf333fbdd14",
"keySecret": "********",
"uuid": "a27767e6-2000-49c2-80ae-6bd6cb8e2873",
"name": "JSON Chief Directives",
"applicationUuid": "17694075-6d09-4df0-8307-90f41de2f35a",
"defaultKey": true,
"status": "ENABLED",
"keySecretHashed": false,
"oauthCallbackUrl": "https://example.com/oauthCallback",
"oauthScope": "OOB",
"oauthType": "public",
"createTs": 1576962923790,
"modifyTs": 1592874748358
}
],
"assets": [
{
"uuid": "76f42917-5833-4938-a115-46534e186077",
Expand Down
44 changes: 44 additions & 0 deletions packages/layer7-apihub-mock/src/handlers/apiKeys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Response } from 'miragejs';
import { promisify } from '../promisify';
import faker from 'faker';

export function listApiKeys(database) {
return async (schema, request) => {
const {
page,
size,
order,
sort,
name,
$select,
...filter
} = request.queryParams;

const finalPage = parseInt(request.queryParams.page, 10);
const finalSize = parseInt(request.queryParams.size, 10);
const [finalSort, finalOrder] = request.queryParams.sort?.split(',') || [];

const finalFilter = {
...filter,
};

const totalElements = (
await promisify(database.apiKeys.find(finalFilter).fetch)
).length;

const results = await promisify(
database.apiKeys.find(finalFilter, {
limit: finalSize,
skip: finalSize * finalPage,
sort: {
[finalSort]: finalOrder?.toLowerCase() === 'asc' ? 1 : -1,
},
}).fetch
);

return {
results: results,
totalElements,
};
};
}
Loading

0 comments on commit e77d6fd

Please sign in to comment.