How to use the frisby.formData function in frisby

To help you get started, we’ve selected a few frisby examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bkimminich / juice-shop / test / api / fileUploadSpec.js View on Github external
xit('POST file type XML with Billion Laughs attack is caught by parser', () => { // FIXME fails with "socket hang up" error from node-fetch
      const file = path.resolve(__dirname, '../files/xxeBillionLaughs.xml')
      const form = frisby.formData()
      form.append('file', fs.createReadStream(file))

      return frisby.post(URL + '/file-upload', {
        headers: { 'Content-Type': form.getHeaders()['content-type'] },
        body: form
      })
        .expect('status', 410)
        .expect('bodyContains', 'Detected an entity reference loop')
    })
github bkimminich / juice-shop / test / api / profileImageUploadSpec.js View on Github external
it('POST profile image file invalid type', () => {
    const file = path.resolve(__dirname, '../files/invalidProfileImageType.docx')
    const form = frisby.formData()
    form.append('file', fs.createReadStream(file))

    return frisby.post(REST_URL + '/user/login', {
      headers: jsonHeader,
      body: {
        email: 'jim@' + config.get('application.domain'),
        password: 'ncc-1701'
      }
    })
      .expect('status', 200)
      .then(({ json: jsonLogin }) => {
        return frisby.post(URL + '/profile/image/file', {
          headers: {
            Cookie: 'token=' + jsonLogin.authentication.token,
            'Content-Type': form.getHeaders()['content-type']
          },
github bkimminich / juice-shop / test / api / memoryApiSpec.js View on Github external
it('POST new memory with valid for JPG format image', () => {
    const file = path.resolve(__dirname, '../files/validProfileImage.jpg')
    const form = frisby.formData()
    form.append('image', fs.createReadStream(file), 'Valid Image')
    form.append('caption', 'Valid Image')

    return frisby.post(REST_URL + '/user/login', {
      headers: jsonHeader,
      body: {
        email: 'jim@' + config.get('application.domain'),
        password: 'ncc-1701'
      }
    })
      .expect('status', 200)
      .then(({ json: jsonLogin }) => {
        return frisby.post(API_URL + '/Memorys', {
          headers: {
            Authorization: 'Bearer ' + jsonLogin.authentication.token,
            'Content-Type': form.getHeaders()['content-type']
github benetech / mmlc-api / spec / error_response_spec.js View on Github external
var create_form = function(filePath, format) {
	var html5Path = path.resolve(__dirname, filePath);
    var form = frisby.formData();
	form.append('outputFormat', format);
    form.append('html5', fs.createReadStream(html5Path));
    return form;
};

frisby

Frisby.js v2.0: REST API Endpoint Testing built on Jasmine

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis