Skip to content

Commit 3cf37fc

Browse files
committed
Add failing test
1 parent 7c2cb34 commit 3cf37fc

4 files changed

Lines changed: 44 additions & 3 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ out/
102102

103103
# mpeltonen/sbt-idea plugin
104104
.idea_modules/
105+
.idea
105106

106107
# JIRA plugin
107108
atlassian-ide-plugin.xml
@@ -116,4 +117,4 @@ crashlytics-build.properties
116117
fabric.properties
117118

118119
# Mocha Awsome
119-
mochawesome-report/*
120+
mochawesome-report/*

test/form-data-swagger.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ paths:
2929
responses:
3030
'200':
3131
description: Import result
32+
/login:
33+
post:
34+
description: Login operation
35+
produces:
36+
- application/json
37+
consumes:
38+
- multipart/form-data
39+
parameters:
40+
- name: username
41+
in: formData
42+
required: true
43+
type: string
44+
description: Authentication username.
45+
- name: password
46+
in: formData
47+
required: true
48+
type: string
49+
description: Authentication password.
50+
responses:
51+
'200':
52+
description: Auth result
3253
definitions:
3354

3455
parameters:
@@ -47,4 +68,4 @@ parameters:
4768
description: 'global request id through the system.'
4869
type: string
4970
minLength: 1
50-
x-example: '123456'
71+
x-example: '123456'

test/middleware-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,5 +2275,21 @@ describe('input-validation middleware tests', function () {
22752275
done();
22762276
});
22772277
});
2278+
it('supports string formData', function (done) {
2279+
request(app)
2280+
.post('/login')
2281+
.set('api-version', '1.0')
2282+
.send({
2283+
username: 'user',
2284+
password: 'pass'
2285+
})
2286+
.expect(200, function (err, res) {
2287+
if (err) {
2288+
throw err;
2289+
}
2290+
expect(res.body.result).to.equal('OK');
2291+
done();
2292+
});
2293+
});
22782294
});
22792295
});

test/test-server-formdata.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ module.exports = inputValidation.init('test/form-data-swagger.yaml', inputValida
2424
app.post('/pets/import', upload.any(), inputValidation.validate, function (req, res, next) {
2525
res.json({ result: 'OK' });
2626
});
27+
app.post('/login', upload.any(), inputValidation.validate, function (req, res, next) {
28+
res.json({ result: 'OK' });
29+
});
2730
app.use(function (err, req, res, next) {
2831
if (err instanceof inputValidation.InputValidationError) {
2932
res.status(400).json({ more_info: err.errors });
@@ -33,4 +36,4 @@ module.exports = inputValidation.init('test/form-data-swagger.yaml', inputValida
3336
module.exports = app;
3437

3538
return Promise.resolve(app);
36-
});
39+
});

0 commit comments

Comments
 (0)