How to use the internal.download function in internal

To help you get started, we’ve selected a few internal 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 arangodb / arangodb / tests / js / client / shell / shell-foxx-cors-spec.js View on Github external
it("sends a CORS options request", function () {
      var opts = { headers: { origin }, method: "OPTIONS" };
      var result = internal.download(origin + "/unittest/headers/header-echo", "", opts);
      expect(result.code).to.equal(200);
      expect(result.headers['access-control-expose-headers']).to.equal('etag, content-encoding, content-length, location, server, x-arango-errors, x-arango-async-id');
      expect(result.headers).not.to.have.property('access-control-allow-headers');
      expect(result.headers['access-control-allow-credentials']).to.equal('true');
      expect(result.headers['access-control-allow-origin']).to.equal(origin);
      expect(result.headers['access-control-allow-methods']).to.equal('DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT');
    });
github arangodb / arangodb / tests / js / client / authentication / foxx-arango-auth-spec.js View on Github external
it('defaults to authenticated user when present', function () {
    const opts = { headers: {
      authorization: (
        'Basic ' + new Buffer('root:').toString('base64')
      )
    }};
    const result = internal.download(url + mount, '', opts);
    expect(result.code).to.equal(200);
    expect(result.body).to.eql(JSON.stringify({user: 'root'}));
  });
github arangodb / arangodb / tests / js / client / authentication / foxx-arango-auth-spec.js View on Github external
it('defaults to authenticated user when present', function () {
    const opts = { headers: {
      authorization: (
        'Basic ' + new Buffer('root:').toString('base64')
      )
    }};
    const result = internal.download(url + mount, '', opts);
    expect(result.code).to.equal(200);
    expect(result.body).to.eql(JSON.stringify({user: 'root'}));
  });
github arangodb / arangodb / tests / js / client / shell / shell-foxx-cors-spec.js View on Github external
it("sets defaults for responses without headers", function () {
      var opts = { headers: { origin }, method: "POST" };
      var result = internal.download(origin + "/unittest/headers/header-empty", "", opts);
      const irrelevantHeaders = ['http/1.1', 'connection', 'content-type'];
      expect(result.headers['access-control-expose-headers']).to.equal(Object.keys(result.headers).filter(x => !x.startsWith('x-content-type-options') && !x.startsWith('access-control-') && !irrelevantHeaders.includes(x)).sort().join(', '));
      expect(result.headers['access-control-allow-credentials']).to.equal('true');
    });
  });
github arangodb / arangodb / tests / js / client / shell / shell-download.js View on Github external
testGetErrorNoReturn : function () {
      var response = internal.download(buildUrlBroken("?foo=1&bar=baz&code=404"),
                                       undefined, { timeout: 300 }, tempName );
      assertEqual(404, response.code);

      assertFalse(fs.exists(tempName));
    },

internal

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages