How to provide authentication credentials to foxx integration tests

85 Views Asked by At

I'm writing integration tests for Foxx service on ArangoDB, similar as described in documentation

However my ArangoDB server is configured with authentication-system-only=false, which means I need to use ArangoDB authentication to use Foxx service. But I don't know how to provide login/password when I run my tests.

Let's say my test file looks like:

"use strict";
const { expect } = require("chai");
const request = require("@arangodb/request");
const { baseUrl } = module.context;
const user = "my_user";
const password = "my_password";

describe("this service", () => {
  it("should say 'Hello World!' at the index route", () => {
    const response = request.get(
          baseUrl, 
          {
              auth: {
                    username: user,
                    password: password
                    }
          });
    expect(response.status).to.equal(200);
    expect(response.body).to.equal("Hello World!");
  });
});

(Note hardcoded login/password I would like to avoid)

I'm running test using : curl -u my_user:my_password -X POST 'http://myarangodb:8529/_db/mydb/_api/foxx/tests?mount=/graph'

Is there a way to provide login/password at test execution ?

  • Perhaps by getting authentication used by launching the test (curl command only works with authentication) ?
  • Perhaps by providing parameters to the command which could be reused in the script ?
0

There are 0 best solutions below