test(integration): used token auth for registry interactions rather than legacy auth
This commit is contained in:
@@ -6,7 +6,7 @@ import got from 'got';
|
||||
import delay from 'delay';
|
||||
import pRetry from 'p-retry';
|
||||
|
||||
const IMAGE = 'verdaccio/verdaccio:4';
|
||||
const IMAGE = 'verdaccio/verdaccio:5';
|
||||
const REGISTRY_PORT = 4873;
|
||||
const REGISTRY_HOST = 'localhost';
|
||||
const NPM_USERNAME = 'integration';
|
||||
@@ -14,7 +14,7 @@ const NPM_PASSWORD = 'suchsecure';
|
||||
const NPM_EMAIL = 'integration@test.com';
|
||||
const docker = new Docker();
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
let container;
|
||||
let container, npmToken;
|
||||
|
||||
/**
|
||||
* Download the `npm-registry-docker` Docker image, create a new container and start it.
|
||||
@@ -55,16 +55,23 @@ export async function start() {
|
||||
email: NPM_EMAIL,
|
||||
},
|
||||
});
|
||||
|
||||
// Create token for user
|
||||
({token: npmToken} = await got(`http://${REGISTRY_HOST}:${REGISTRY_PORT}/-/npm/v1/tokens`, {
|
||||
username: NPM_USERNAME,
|
||||
password: NPM_PASSWORD,
|
||||
method: 'POST',
|
||||
headers: {'content-type': 'application/json'},
|
||||
json: {password: NPM_PASSWORD, readonly: false, cidr_whitelist: []}
|
||||
}).json());
|
||||
}
|
||||
|
||||
export const url = `http://${REGISTRY_HOST}:${REGISTRY_PORT}/`;
|
||||
|
||||
export const authEnv = {
|
||||
export const authEnv = () => ({
|
||||
npm_config_registry: url, // eslint-disable-line camelcase
|
||||
NPM_USERNAME,
|
||||
NPM_PASSWORD,
|
||||
NPM_EMAIL,
|
||||
};
|
||||
NPM_TOKEN: npmToken,
|
||||
});
|
||||
|
||||
/**
|
||||
* Stop and remote the `npm-registry-docker` Docker container.
|
||||
|
||||
Reference in New Issue
Block a user