generated from digicatapult/openapi-service-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from digicatapult/feat/initial-integration-tests
Initial integration tests
- Loading branch information
Showing
12 changed files
with
642 additions
and
76 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
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
Binary file not shown.
Binary file not shown.
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,66 @@ | ||
import request from 'supertest' | ||
import express from 'express' | ||
|
||
export async function getOutOfBoundsReadAarch64( | ||
app: express.Express, | ||
password: string | number, | ||
firstOffset: string | number, | ||
secondOffset: string | number | ||
) { | ||
return request(app) | ||
.get(`/scenario/out-of-bounds-readV2-aarch64?params=${password}¶ms=${firstOffset}¶ms=${secondOffset}`) | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.send() | ||
.then((response) => { | ||
return response | ||
}) | ||
.catch((err) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Out of bounds read (aaarch64) ${err}`) | ||
return err | ||
}) | ||
} | ||
|
||
export async function getOutOfBoundsReadCheri( | ||
app: express.Express, | ||
password: string | number, | ||
firstOffset: string | number, | ||
secondOffset: string | number | ||
) { | ||
return request(app) | ||
.get(`/scenario/out-of-bounds-readV2-cheri?params=${password}¶ms=${firstOffset}¶ms=${secondOffset}`) | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.send() | ||
.then((response) => { | ||
return response | ||
}) | ||
.catch((err) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Out of bounds read (aaarch64) ${err}`) | ||
return err | ||
}) | ||
} | ||
|
||
export async function getInvalidExecutable(app: express.Express, password: string | number) { | ||
return request(app) | ||
.get(`/scenario/out-of-bounds-readV5-aarch64?params=${password}`) | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.send() | ||
.then((response) => { | ||
return response | ||
}) | ||
.catch((err) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Out of bounds read (aaarch64) ${err}`) | ||
return err | ||
}) | ||
} | ||
|
||
module.exports = { | ||
getOutOfBoundsReadAarch64, | ||
getOutOfBoundsReadCheri, | ||
getInvalidExecutable, | ||
} |
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,82 @@ | ||
import { describe, before, test } from 'mocha' | ||
import { expect } from 'chai' | ||
import express from 'express' | ||
import { CreateHttpServer } from '../src/server' | ||
import { | ||
getOutOfBoundsReadCheri, | ||
getOutOfBoundsReadAarch64, | ||
getInvalidExecutable, | ||
} from '../integration/helper/routeHelper' | ||
|
||
describe('Tests aarch64 version', () => { | ||
let app: express.Express | ||
|
||
before(async function () { | ||
app = await CreateHttpServer() | ||
}) | ||
|
||
test('Happy Path - aarch64', async () => { | ||
const response = await getOutOfBoundsReadAarch64(app, 'pass', -32, -28) | ||
|
||
expect(response.status).to.equal(200) | ||
expect(response.body.output).to.contain('Storing Secret...\nThe data between indices -32 and -28 is: pass\n') | ||
expect(response.body.status).to.contain('success') | ||
}) | ||
|
||
test('Bad Parameters - aarch64', async () => { | ||
const response = await getOutOfBoundsReadAarch64(app, 'badpass', NaN, 'ttttttt') | ||
|
||
expect(response.status).to.equal(200) | ||
expect(response.body.status).to.contain('success') | ||
}) | ||
|
||
test('Missing Parameters - aarch64', async () => { | ||
const response = await getOutOfBoundsReadAarch64(app, 'badpass', '', '') | ||
|
||
expect(response.status).to.equal(200) | ||
expect(response.body.status).to.contain('success') | ||
}) | ||
}) | ||
|
||
describe('Tests Cheri version', () => { | ||
let app: express.Express | ||
|
||
before(async () => { | ||
app = await CreateHttpServer() | ||
}) | ||
|
||
test('Happy Path - cheri', async () => { | ||
const response = await getOutOfBoundsReadCheri(app, 'cheripass', -32, -21) | ||
|
||
expect(response.status).to.equal(200) | ||
expect(response.body.status).to.contain('error') | ||
}) | ||
|
||
test('Bad Parameters - cheri', async () => { | ||
const response = await getOutOfBoundsReadCheri(app, 'cheripass', 'cube', 'tarmac') | ||
|
||
expect(response.status).to.equal(200) | ||
expect(response.body.status).to.contain('success') | ||
}) | ||
|
||
test('Missing Parameters - cheri', async () => { | ||
const response = await getOutOfBoundsReadCheri(app, 'cheripass', '', '') | ||
|
||
expect(response.status).to.equal(200) | ||
expect(response.body.status).to.contain('success') | ||
}) | ||
}) | ||
|
||
describe('Tests Invalid Executable version', () => { | ||
let app: express.Express | ||
|
||
before(async () => { | ||
app = await CreateHttpServer() | ||
}) | ||
|
||
test('Sad Path - non-existant test', async () => { | ||
const response = await getInvalidExecutable(app, 'invalidpass') | ||
|
||
expect(response.status).to.equal(422) | ||
}) | ||
}) |
Oops, something went wrong.