-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REST: Add 403 response spec test for all edit routes
Bug: T375067 Change-Id: I5666051757a2f30c253decbf88f65b2f97008c9b
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
repo/rest-api/tests/mocha/openapi-validation/PermissionDeniedResponseTest.js
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,25 @@ | ||
'use strict'; | ||
|
||
const { describeWithTestData } = require( '../helpers/describeWithTestData' ); | ||
const { | ||
getItemEditRequests, | ||
getPropertyEditRequests, | ||
getItemCreateRequest | ||
} = require( '../helpers/happyPathRequestBuilders' ); | ||
const { expect } = require( '../helpers/chaiHelper' ); | ||
describeWithTestData( '403 for all edit routes', ( itemRequestInputs, propertyRequestInputs ) => { | ||
[ | ||
...getItemEditRequests( itemRequestInputs ), | ||
...getPropertyEditRequests( propertyRequestInputs ), | ||
getItemCreateRequest( itemRequestInputs ) | ||
].forEach( ( { newRequestBuilder } ) => { | ||
it( `${newRequestBuilder().getRouteDescription()} responds with a valid 403 response`, async () => { | ||
const response = await newRequestBuilder() | ||
.withJsonBodyParam( 'bot', true ) | ||
.makeRequest(); | ||
|
||
expect( response ).to.have.status( 403 ); | ||
expect( response ).to.satisfyApiSpec; | ||
} ); | ||
} ); | ||
} ); |