Skip to content

Commit 73d0b1b

Browse files
authored
Merge pull request #1031 from bcgov/test
Create Latest Release
2 parents 4ec063b + 7b1cf07 commit 73d0b1b

File tree

14 files changed

+268
-22
lines changed

14 files changed

+268
-22
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The repo is setup to create a local deployment of the Portal along with required
2626
docker build -t gwa-api:e2e .
2727
```
2828
29-
1. Build: Back in `api-services-portal`, run `docker compose --profile testsuite build`.
29+
1. Build: Back in `api-services-portal`, run `docker compose build`.
3030
1. Run: `docker compose up`. Wait for startup to complete - look for `Swagger UI registered`.
3131
1. The Portal is now live at http://oauth2proxy.localtest.me:4180
3232
1. To login, use username `janis@idir` and password `awsummer` (or username `local` and password `local`).
@@ -35,7 +35,12 @@ The repo is setup to create a local deployment of the Portal along with required
3535
3636
### Cypress testing
3737
38-
To run the Cypress test automation suite, run `docker compose --profile testsuite up`.
38+
To run the Cypress test automation suite, run
39+
40+
```sh
41+
docker compose --profile testsuite build
42+
docker compose --profile testsuite up
43+
```
3944

4045
### gwa CLI configuration
4146

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ x-common-variables: &common-variables
99

1010
services:
1111
keycloak:
12-
image: jboss/keycloak:15.1.1
12+
image: quay.io/keycloak/keycloak:15.1.1
1313
container_name: keycloak
1414
hostname: keycloak
1515
depends_on:

src/mocks/resolvers/api-directory.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,77 @@
1+
import YAML from 'js-yaml';
2+
3+
const markdown = YAML.load(`
4+
notes: |
5+
Here is some markdown.
6+
# Heading 1
7+
## Heading 2
8+
### Heading 3
9+
#### Heading 4
10+
Then I will do **bold**, _italics_ and ~~strikethrough~~.
11+
12+
#### Heading 4
13+
14+
And some text.
15+
16+
How about a table?
17+
| Col1 | Col2 |
18+
| ---- | ---- |
19+
| Val1 | Val2 |
20+
21+
How about a new line.
22+
23+
And another line.
24+
25+
Try a list:
26+
- one
27+
- two
28+
- three
29+
30+
Or an ordered list:
31+
1. one
32+
1. two
33+
1. three
34+
35+
Then there are images
36+
37+
![image](http://localhost:3000/images/bc_logo_header.svg)
38+
39+
And links [my docs](https://github.com).
40+
41+
Here are some block quotes
42+
43+
> A block quote about something.
44+
45+
What about a bit of code - \`alert("hi")\`.
46+
47+
Code block?
48+
\`\`\`
49+
function (a) {
50+
// comment
51+
}
52+
\`\`\`
53+
54+
`);
55+
156
const directories = [
57+
{
58+
id: 'api1',
59+
name: 'markdown-test',
60+
title: 'Testing Markdown on Dataset',
61+
notes: markdown.notes,
62+
sector: 'Natural Resources',
63+
license_title: 'Access Only',
64+
view_audience: 'Named users',
65+
security_class: 'LOW-PUBLIC',
66+
record_publish_date: '2020-04-28',
67+
tags: '["API","CDOGS","Document","Document Generation"]',
68+
organization: {
69+
title: 'Ministry of Environment and Climate Change Strategy',
70+
},
71+
organizationUnit: {
72+
title: 'Information Innovation and Technology',
73+
},
74+
},
275
{
376
id: 'api1',
477
name: 'common-service-api',

src/nextapp/pages/devportal/api-directory/[id].tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ReactMarkdownWithHtml from 'react-markdown/with-html';
2626
import gfm from 'remark-gfm';
2727
import { uid } from 'react-uid';
2828
import { useAuth } from '@/shared/services/auth';
29+
import style from '@/shared/styles/markdown.module.css';
2930

3031
const renderers = {
3132
link: InternalLink,
@@ -144,20 +145,28 @@ const ApiPage: React.FC<
144145
<Heading size="sm">About This Dataset</Heading>
145146
</Box>
146147
<Box mt={5} mb={9} sx={{ p: { marginBottom: 4 } }}>
147-
<ReactMarkdownWithHtml renderers={renderers} plugins={[gfm]}>
148+
<ReactMarkdownWithHtml
149+
renderers={renderers}
150+
plugins={[gfm]}
151+
className={style.markdown}
152+
>
148153
{data?.notes}
149154
</ReactMarkdownWithHtml>
150155
</Box>
151156
<Card heading="Products">
152157
<Box bg="gray.100">
153-
{data?.products?.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)).map((p) => (
154-
<ApiProductItem
155-
key={uid(p)}
156-
data={p}
157-
id={p.id}
158-
preview={preview}
159-
/>
160-
))}
158+
{data?.products
159+
?.sort((a, b) =>
160+
a.name > b.name ? 1 : b.name > a.name ? -1 : 0
161+
)
162+
.map((p) => (
163+
<ApiProductItem
164+
key={uid(p)}
165+
data={p}
166+
id={p.id}
167+
preview={preview}
168+
/>
169+
))}
161170
</Box>
162171
</Card>
163172
</GridItem>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
.markdown {
2+
}
3+
4+
.markdown h1 {
5+
margin-bottom: 1em;
6+
}
7+
8+
.markdown h2 {
9+
margin-bottom: 1em;
10+
}
11+
12+
.markdown h3 {
13+
margin-bottom: 1em;
14+
}
15+
16+
.markdown h4 {
17+
margin-bottom: 1em;
18+
}
19+
20+
.markdown ul {
21+
margin-top: 1em;
22+
margin-bottom: 1em;
23+
list-style: disc outside none;
24+
}
25+
26+
.markdown ul li {
27+
margin-left: 2em;
28+
display: list-item;
29+
text-align: -webkit-match-parent;
30+
}
31+
32+
.markdown ol {
33+
margin-top: 1em;
34+
margin-bottom: 1em;
35+
}
36+
37+
.markdown ol li {
38+
margin-left: 2em;
39+
display: list-item;
40+
text-align: -webkit-match-parent;
41+
}
42+
43+
.markdown img {
44+
display: none;
45+
}
46+
47+
.markdown table {
48+
margin-top: 1em;
49+
margin-bottom: 1em;
50+
width: 100%;
51+
border-collapse: collapse;
52+
}
53+
54+
.markdown td {
55+
padding: 8px;
56+
border: 1px solid #cccccc;
57+
}
58+
59+
.markdown th {
60+
padding: 8px;
61+
text-align: left;
62+
border: 1px solid #cccccc;
63+
}
64+
65+
.markdown blockquote {
66+
margin-top: 1em;
67+
margin-bottom: 1em;
68+
padding-top: 5px;
69+
padding-bottom: 5px;
70+
padding-left: 5px;
71+
border-left: 10px solid #cccccc;
72+
}

src/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"copy-keystone-admin-assets": "ts-node tools/copyKeystoneAdminAssets",
3434
"x-prestart": "npm run build",
3535
"x-dev": "nodemon",
36+
"nextapp-dev": "cross-env NEXT_PUBLIC_MOCKS=on NODE_ENV=development NODE_OPTIONS='--openssl-legacy-provider --no-experimental-fetch --dns-result-order=ipv4first' next dev ./nextapp",
3637
"batch": "cross-env NODE_ENV=development node dist/server-batch.js",
3738
"intg-build": "cross-env NODE_ENV=development npm-run-all delete-assets copy-assets ts-build",
3839
"dev": "cross-env NODE_ENV=development NODE_OPTIONS='--openssl-legacy-provider --no-experimental-fetch --dns-result-order=ipv4first' npm-run-all delete-assets copy-assets tsoa-gen-types tsoa-build-v1 tsoa-build-v2 ts-build ks-dev",

src/services/keystone/application.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export async function lookupApplication(
1212
allApplications(where: {id: $id}) {
1313
id
1414
appId
15+
name
16+
owner {
17+
name
18+
}
1519
}
1620
}`,
1721
variables: { id },

src/services/kong/consumer-service.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
KeyAuthResponse,
1111
KongConsumer,
1212
} from './types';
13+
import { Application } from '../keystone/types';
14+
import { alphanumericNoSpaces } from '../utils';
1315

1416
const logger = Logger('kong.consumer');
1517

@@ -41,7 +43,8 @@ export class KongConsumerService {
4143

4244
public async createOrGetConsumer(
4345
username: string,
44-
customId: string
46+
customId: string,
47+
app: Application
4548
): Promise<CreateOrGetConsumerResult> {
4649
logger.debug('createOrGetConsumer');
4750
try {
@@ -51,20 +54,28 @@ export class KongConsumerService {
5154
return { created: false, consumer: result };
5255
} catch (err) {
5356
logger.debug('createOrGetConsumer - CATCH ERROR %s', err);
54-
const result = await this.createKongConsumer(username, customId);
57+
const result = await this.createKongConsumer(username, customId, app);
5558
logger.debug('createOrGetConsumer - CATCH RESULT %j', result);
56-
return { created: false, consumer: result };
59+
return { created: true, consumer: result };
5760
}
5861
}
5962

60-
public async createKongConsumer(username: string, customId: string) {
63+
public async createKongConsumer(
64+
username: string,
65+
customId: string,
66+
app: Application
67+
) {
6168
let body: KongConsumer = {
6269
username: username,
63-
tags: ['aps-portal'],
70+
tags: [],
6471
};
6572
if (customId) {
6673
body['custom_id'] = customId;
6774
}
75+
if (app) {
76+
body.tags.push(`app:${alphanumericNoSpaces(app.name)}`);
77+
body.tags.push(`owner:${alphanumericNoSpaces(app.owner.name)}`);
78+
}
6879
logger.debug('[createKongConsumer] %s', `${this.kongUrl}/consumers`);
6980
try {
7081
let response = await fetch(`${this.kongUrl}/consumers`, {

src/services/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ export async function fetchWithTimeout(resource: string, options: any = {}) {
7575

7676
return response;
7777
}
78+
79+
export function alphanumericNoSpaces(str: string) {
80+
return str.replace(/[^A-Za-z0-9:-]/gim, '').replace(/[:]/gim, '-');
81+
}

src/services/workflow/create-service-account.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ export const CreateServiceAccount = async (
7979
const nickname = client.client.clientId;
8080

8181
const kongApi = new KongConsumerService(process.env.KONG_URL);
82-
const consumer = await kongApi.createKongConsumer(nickname, clientId);
82+
const consumer = await kongApi.createKongConsumer(
83+
nickname,
84+
clientId,
85+
application
86+
);
8387
const consumerPK = await AddClientConsumer(
8488
context,
8589
nickname,

0 commit comments

Comments
 (0)