<commit_before>var assert      = require('assert');
var Promise     = require('promise');
var path        = require('path');
var _           = require('lodash');
var testing     = require('taskcluster-lib-testing');
var data        = require('../lib/data');
var v1          = require('../lib/v1');
var taskcluster = require('taskcluster-client');
var mocha       = require('mocha');
var serverLoad  = require('../lib/main');
var exchanges   = require('../lib/exchanges');
var testserver  = require('./testserver');
var slugid      = require('slugid');
var Config      = require('typed-env-config');

// Load configuration
var cfg = Config({profile: 'test'});

// Create subject to be tested by test
var helper = module.exports = {};

helper.cfg = cfg;
helper.testaccount = _.keys(cfg.app.azureAccounts)[0];
helper.rootAccessToken = cfg.app.rootAccessToken;

// Skip tests if no pulse credentials are configured
if (!cfg.pulse.password) {
  console.log("Skip tests for due to missing pulse credentials; " +
              "create user-config.yml");
  process.exit(1);
}

// Configure PulseTestReceiver
helper.events = new testing.PulseTestReceiver(cfg.pulse, mocha);

var webServer = null, testServer;
mocha.before(async () => {
  let overwrites = {};
  overwrites['profile'] = 'test';
  overwrites['process'] = 'test';
  helper.overwrites = overwrites;
  helper.load = serverLoad;

  // if we don't have an azure account/key, use the inmemory version
  if (!cfg.azure || !cfg.azure.accountName) {
    let resolver = await serverLoad('resolver', overwrites);
    let signingKey = cfg.app.tableSigningKey;
    let cryptoKey = cfg.app.tableCryptoKey;
    overwrites['resolver'] = resolver;
    overwrites['Client'] = data.Client.setup({
      table: 'Client',
      account: 'inMemory',
      cryptoKey,
      signingKey,
      context: {resolver},
    });
    overwrites['Role'] = data.Role.setup({
      table: 'Role',
      account: 'inMemory',
      signingKey,
      context: {resolver},
    });
  }

  webServer = await serverLoad('server', overwrites);
  webServer.setTimeout(3500); // >3s because Azure can be sloooow

  // Create client for working with API
  helper.baseUrl = 'http://localhost:' + webServer.address().port + '/v1';
  var reference = v1.reference({baseUrl: helper.baseUrl});
  assert(reference.entries.length == 19, "Something is missing");
  helper.Auth = taskcluster.createClient(reference);
  helper.auth = new helper.Auth({
    baseUrl:          helper.baseUrl,
    credentials: {
      clientId:       'root',
      accessToken:    cfg.app.rootAccessToken,
    }<commit_msg>Check reference object 2<commit_after>var assert      = require('assert');
var Promise     = require('promise');
var path        = require('path');
var _           = require('lodash');
var testing     = require('taskcluster-lib-testing');
var data        = require('../lib/data');
var v1          = require('../lib/v1');
var taskcluster = require('taskcluster-client');
var mocha       = require('mocha');
var serverLoad  = require('../lib/main');
var exchanges   = require('../lib/exchanges');
var testserver  = require('./testserver');
var slugid      = require('slugid');
var Config      = require('typed-env-config');

// Load configuration
var cfg = Config({profile: 'test'});

// Create subject to be tested by test
var helper = module.exports = {};

helper.cfg = cfg;
helper.testaccount = _.keys(cfg.app.azureAccounts)[0];
helper.rootAccessToken = cfg.app.rootAccessToken;

// Skip tests if no pulse credentials are configured
if (!cfg.pulse.password) {
  console.log("Skip tests for due to missing pulse credentials; " +
              "create user-config.yml");
  process.exit(1);
}

// Configure PulseTestReceiver
helper.events = new testing.PulseTestReceiver(cfg.pulse, mocha);

var webServer = null, testServer;
mocha.before(async () => {
  let overwrites = {};
  overwrites['profile'] = 'test';
  overwrites['process'] = 'test';
  helper.overwrites = overwrites;
  helper.load = serverLoad;

  // if we don't have an azure account/key, use the inmemory version
  if (!cfg.azure || !cfg.azure.accountName) {
    let resolver = await serverLoad('resolver', overwrites);
    let signingKey = cfg.app.tableSigningKey;
    let cryptoKey = cfg.app.tableCryptoKey;
    overwrites['resolver'] = resolver;
    overwrites['Client'] = data.Client.setup({
      table: 'Client',
      account: 'inMemory',
      cryptoKey,
      signingKey,
      context: {resolver},
    });
    overwrites['Role'] = data.Role.setup({
      table: 'Role',
      account: 'inMemory',
      signingKey,
      context: {resolver},
    });
  }

  webServer = await serverLoad('server', overwrites);
  webServer.setTimeout(3500); // >3s because Azure can be sloooow

  // Create client for working with API
  helper.baseUrl = 'http://localhost:' + webServer.address().port + '/v1';
  var reference = v1.reference({baseUrl: helper.baseUrl});
  assert(reference.entries.length == 18, "I don't get it");
  helper.Auth = taskcluster.createClient(reference);
  helper.auth = new helper.Auth({
    baseUrl:          helper.baseUrl,
    credentials: {
      clientId:       'root',
      accessToken:    cfg.app.rootAccessToken,
    }
{'fraction_non_alphanumeric': 0.14768580756673708, 'fraction_numerical': 0.0051853274438256195, 'mean_word_length': 3.3363863447127393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1624367', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1568, 'n_words': 390}