How to use the @cumulus/common/test-utils.randomId function in @cumulus/common

To help you get started, we’ve selected a few @cumulus/common 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 nasa / cumulus / packages / api / lib / testUtils.js View on Github external
function fakeUserFactory(params = {}) {
  const user = {
    userName: randomId('userName'),
    password: randomId('password'),
    expires: Date.now() + (60 * 60 * 1000) // Default to 1 hour
  };

  return { ...user, ...params };
}
github nasa / cumulus / packages / api / app / distribution-routes.js View on Github external
async function ensureAuthorizedOrRedirect(req, res, next) {
  // Skip authentication for debugging purposes.
  if (process.env.FAKE_AUTH) {
    req.authorizedMetadata = { userName: randomId('username') };
    return next();
  }

  // Public data doesn't need authentication
  if (isPublicRequest(req.path)) {
    req.authorizedMetadata = { userName: 'unauthenticated user' };
    return next();
  }

  const {
    accessTokenModel,
    authClient
  } = getConfigurations();

  const redirectURLForAuthorizationCode = authClient.getAuthorizationUrl(req.path);
  const accessToken = req.cookies.accessToken;
github nasa / cumulus / packages / api / lib / testUtils.js View on Github external
function fakeGranuleFactory(status = 'completed') {
  return {
    granuleId: randomId('granule'),
    dataType: randomId('datatype'),
    version: randomId('vers'),
    collectionId: 'fakeCollection___v1',
    status,
    execution: randomString(),
    createdAt: Date.now(),
    updatedAt: Date.now(),
    published: true,
    cmrLink: 'example.com',
    productVolume: 100
  };
}
github nasa / cumulus / packages / api / lib / testUtils.js View on Github external
function fakeGranuleFactory(status = 'completed') {
  return {
    granuleId: randomId('granule'),
    dataType: randomId('datatype'),
    version: randomId('vers'),
    collectionId: 'fakeCollection___v1',
    status,
    execution: randomString(),
    createdAt: Date.now(),
    updatedAt: Date.now(),
    published: true,
    cmrLink: 'example.com',
    productVolume: 100
  };
}
github nasa / cumulus / packages / api / lib / testUtils.js View on Github external
function fakeAccessTokenFactory(params = {}) {
  return {
    accessToken: randomId('accessToken'),
    refreshToken: randomId('refreshToken'),
    username: randomId('username'),
    expirationTime: Date.now() + (60 * 60 * 1000),
    ...params
  };
}
github nasa / cumulus / packages / api / bin / serve.js View on Github external
function setAuthEnvVariables() {
  if (process.env.FAKE_AUTH) {
    process.env.EARTHDATA_CLIENT_ID = randomId('EARTHDATA_CLIENT_ID');
    process.env.EARTHDATA_CLIENT_PASSWORD = randomId('EARTHDATA_CLIENT_PASSWORD');
    process.env.EARTHDATA_BASE_URL = 'https://example.com';
  }
}