Skip to content

Commit c10769e

Browse files
Posting events to Submission API
1 parent 9f5cf10 commit c10769e

File tree

10 files changed

+986
-955
lines changed

10 files changed

+986
-955
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following parameters can be set in config files or in env variables:
2626
- DMZ_BUCKET: the DMZ bucket
2727
- CLEAN_BUCKET: the clean bucket
2828
- QUARANTINE_BUCKET: quarantine bucket
29-
- REVIEW_API_URL: the review API URL
29+
- SUBMISSION_API_URL: Submission API URL
3030
- ANTIVIRUS_API_URL: Antivirus API URL
3131

3232
Note that ACCESS_KEY_ID and SECRET_ACCESS_KEY are optional,
@@ -72,9 +72,8 @@ Also note that there is a `/health` endpoint that checks for the health of the a
7272
- install dependencies `npm i`
7373
- run code lint check `npm run lint`, running `npm run lint:fix` can fix some lint errors if any
7474
- start app `npm start`
75-
- use another terminal to start mock review api `npm run mock-review-api`
76-
the mock review api is running at `http://localhost:5000`
77-
- **You can also run the application and mock review API together by executing the command `npm run docker-start`**
75+
- use another terminal to start mock submission api `npm run mock-submission-api`
76+
the mock submission api is running at `http://localhost:3010/api/v5`
7877

7978
- Anti virus API configured using `ANTIVIRUS_API_URL` should be up and running for the application to work properly.
8079

@@ -102,7 +101,7 @@ docker-compose up
102101

103102
Ideally, Unit tests should use mocks for all external interactions. In AWS S3 mocks available, there is no option available to return different files based on some conditions, Also for Anti Virus API, there is no identifier to differentiate between good file and infected file to return mock responses.
104103

105-
Hence for unit tests, S3 and Anti virus API should be real and Review API will be mocked.
104+
Hence for unit tests, S3 and Anti virus API should be real and Submission API will be mocked.
106105

107106
Tests uses separate S3 buckets which need to be configured using the environment variables
108107

@@ -144,7 +143,7 @@ npm run cov-e2e
144143

145144
## Verification
146145

147-
- start kafka server, start mock review api, setup 3 AWS S3 buckets and update corresponding config, start processor app, start Anti virus service or configure Remote Anti virus service
146+
- start kafka server, start mock submission api, setup 3 AWS S3 buckets and update corresponding config, start processor app, start Anti virus service or configure Remote Anti virus service
148147
- use the above kafka-console-producer to write messages to `submission.notification.create` topic, one message per line:
149148

150149
```
@@ -156,5 +155,5 @@ npm run cov-e2e
156155

157156
similarly add more messages, the files will be moved to clean or quarantine areas depending on the result from Anti virus API
158157
- go to AWS console S3 service, check the 3 buckets contents
159-
- check the mock review api console, it should say getting some review data
158+
- check the mock submission api console, it should say Mock Submission API got some data
160159

config/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
QUARANTINE_BUCKET: process.env.QUARANTINE_BUCKET
1818
},
1919

20-
REVIEW_API_URL: process.env.REVIEW_API_URL || 'http://localhost:5000/reviews',
20+
SUBMISSION_API_URL: process.env.SUBMISSION_API_URL || 'http://localhost:3010/api/v5',
2121
ANTIVIRUS_API_URL: process.env.ANTIVIRUS_API_URL || 'http://localhost:3000/api/v1/scan',
2222

2323
AUTH0_URL: process.env.AUTH0_URL, // Auth0 credentials for Submission Service

docker/sample.api.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ REGION=<AWS Region>
55
DMZ_BUCKET=<AWS DMZ Bucket Name>
66
CLEAN_BUCKET=<AWS Clean Bucket Name>
77
QUARANTINE_BUCKET=<AWS Quarantine Bucket Name>
8-
REVIEW_API_URL=<Review API URL>
8+
SUBMISSION_API_URL=<Review API URL>
99
ANTIVIRUS_API_URL=<Antivirus API URL>

mock-review-api/api.js renamed to mock-submission-api/api.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ const bodyParser = require('body-parser')
77
const logger = require('../src/common/logger')
88

99
const app = express()
10-
app.set('port', process.env.MOCK_REVIEW_API_PORT || 5000)
10+
app.set('port', process.env.MOCK_SUBMISSION_API_PORT || 3010)
1111

1212
app.use(cors())
1313
app.use(bodyParser.json())
1414
app.use(bodyParser.urlencoded({ extended: true }))
1515

16-
app.post('/reviews', (req, res) => {
17-
logger.info('Mock review API got data:')
16+
app.post('/api/v5/reviews', (req, res) => {
17+
logger.info('Mock Submission API got data:')
18+
logger.info(JSON.stringify(req.body, null, 4))
19+
res.status(200).end()
20+
})
21+
22+
app.patch('/api/v5/submissions/:submissionId', (req, res) => {
23+
logger.info('Mock Submission API got data:')
1824
logger.info(JSON.stringify(req.body, null, 4))
1925
res.status(200).end()
2026
})

0 commit comments

Comments
 (0)