[tests] Remove disableSSO() function (#11380)

The SSO Protection feature is now turned off by default for testing accounts. So this manual logic for disabling the feature on each project test fixture is no longer necessary.
This commit is contained in:
Nathan Rajlich
2024-04-06 00:47:56 -07:00
committed by GitHub
parent 0c3d136414
commit 3e57c4a2de
7 changed files with 8 additions and 129 deletions

View File

@@ -7,7 +7,6 @@ const { satisfies } = require('semver');
const stripAnsi = require('strip-ansi');
const {
fetchCachedToken,
disableSSO,
} = require('../../../../test/lib/deployment/now-deploy');
const { spawnSync, execFileSync } = require('child_process');
@@ -399,9 +398,6 @@ function testFixtureStdio(
// Expect the deploy succeeded with exit of 0;
expect(deployResult.exitCode).toBe(0);
deploymentUrl = new URL(deployResult.stdout).host;
// Disable the Project SSO Protection
await disableSSO(deployResult.stdout, true);
} finally {
if (!hasGitignore) {
await fs.remove(gitignore);

View File

@@ -5,10 +5,7 @@ import fetch, { RequestInit } from 'node-fetch';
import retry from 'async-retry';
import fs from 'fs-extra';
import sleep from '../src/util/sleep';
import {
disableSSO,
fetchTokenWithRetry,
} from '../../../test/lib/deployment/now-deploy';
import { fetchTokenWithRetry } from '../../../test/lib/deployment/now-deploy';
import waitForPrompt from './helpers/wait-for-prompt';
import { listTmpDirs } from './helpers/get-tmp-dir';
import getGlobalDir from './helpers/get-global-dir';
@@ -405,7 +402,6 @@ test('default command should work with --cwd option', async () => {
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
const url = stdout;
await disableSSO(url, false);
const deploymentResult = await fetch(`${url}/README.md`);
const body = await deploymentResult.text();
@@ -435,7 +431,6 @@ test('should allow deploying a directory that was built with a target environmen
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
const url = stdout;
await disableSSO(url, false);
const deploymentResult = await fetch(`${url}/README.md`);
const body = await deploymentResult.text();
@@ -463,7 +458,6 @@ test('should allow deploying a directory that was prebuilt, but has no builds.js
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
const url = stdout;
await disableSSO(url, false);
const deploymentResult = await fetch(`${url}/README.md`);
const body = await deploymentResult.text();
@@ -527,7 +521,6 @@ test('deploy using only now.json with `redirects` defined', async () => {
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
const url = stdout;
await disableSSO(url, false);
const res = await fetch(`${url}/foo/bar`, { redirect: 'manual' });
const location = res.headers.get('location');
expect(location).toBe('https://example.com/foo/bar');
@@ -549,7 +542,6 @@ test('deploy using --local-config flag v2', async () => {
const { host } = new URL(stdout);
expect(host).toMatch(/secondary/gm);
await disableSSO(host, false);
const testRes = await fetch(`https://${host}/test-${contextName}.html`);
const testText = await testRes.text();
@@ -631,7 +623,6 @@ test('deploy using --local-config flag above target', async () => {
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
const { host } = new URL(stdout);
await disableSSO(host, false);
const testRes = await fetch(`https://${host}/index.html`);
const testText = await testRes.text();
@@ -853,7 +844,6 @@ test('Deploy `api-env` fixture and test `vercel env` command', async () => {
});
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
const { host } = new URL(stdout);
await disableSSO(host, false);
const apiUrl = `https://${host}/api/get-env`;
const apiRes = await fetch(apiUrl);

View File

@@ -11,10 +11,7 @@ import fs, {
mkdir,
} from 'fs-extra';
import sleep from '../src/util/sleep';
import {
disableSSO,
fetchTokenWithRetry,
} from '../../../test/lib/deployment/now-deploy';
import { fetchTokenWithRetry } from '../../../test/lib/deployment/now-deploy';
import waitForPrompt from './helpers/wait-for-prompt';
import { execCli } from './helpers/exec';
import getGlobalDir from './helpers/get-global-dir';
@@ -330,8 +327,7 @@ test('should show prompts to set up project during first deploy', async () => {
'README.txt'
).toBe(true);
const { host, href } = new URL(output.stdout);
await disableSSO(host, false);
const { href } = new URL(output.stdout);
// Send a test request to the deployment
const response = await fetch(href);
@@ -646,8 +642,7 @@ test('use `rootDirectory` from project when deploying', async () => {
const secondResult = await execCli(binaryPath, [directory, '--public']);
expect(secondResult.exitCode, formatOutput(secondResult)).toBe(0);
const { host, href } = new URL(secondResult.stdout);
await disableSSO(host, false);
const { href } = new URL(secondResult.stdout);
const pageResponse1 = await fetch(href);
expect(pageResponse1.status).toBe(200);
@@ -778,7 +773,6 @@ test('deploys with only now.json and README.md', async () => {
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
const { host } = new URL(stdout);
await disableSSO(host, false);
const res = await fetch(`https://${host}/README.md`);
const text = await res.text();
expect(text).toMatch(/readme contents/);
@@ -801,7 +795,6 @@ test('deploys with only vercel.json and README.md', async () => {
);
const { host } = new URL(stdout);
await disableSSO(host, false);
const res = await fetch(`https://${host}/README.md`);
const text = await res.text();
expect(text).toMatch(/readme contents/);
@@ -887,7 +880,6 @@ test('deploy pnpm twice using pnp and symlink=false', async () => {
'--public',
'--yes',
]);
await disableSSO(res.stdout, false);
return res;
}
@@ -1344,8 +1336,6 @@ test('vercel.json configuration overrides in a new project prompt user and merge
const deployment = await vc;
expect(deployment.exitCode, formatOutput(deployment)).toBe(0);
// assert the command were executed
await disableSSO(deployment.stdout, false);
let page = await fetch(deployment.stdout);
let text = await page.text();
expect(text).toBe('1\n');
@@ -1376,8 +1366,7 @@ test('vercel.json configuration overrides in an existing project do not prompt u
// auto-confirm this deployment
let deployment = await deploy(true);
const { host, href } = new URL(deployment.stdout);
await disableSSO(host, false);
const { href } = new URL(deployment.stdout);
let page = await fetch(href);
let text = await page.text();
expect(text).toBe('0');

View File

@@ -14,10 +14,7 @@ import { logo } from '../src/util/pkg-name';
import sleep from '../src/util/sleep';
import humanizePath from '../src/util/humanize-path';
import pkg from '../package.json';
import {
disableSSO,
fetchTokenWithRetry,
} from '../../../test/lib/deployment/now-deploy';
import { fetchTokenWithRetry } from '../../../test/lib/deployment/now-deploy';
import waitForPrompt from './helpers/wait-for-prompt';
import { getNewTmpDir, listTmpDirs } from './helpers/get-tmp-dir';
import getGlobalDir from './helpers/get-global-dir';
@@ -312,7 +309,6 @@ test('should add secret with hyphen prefix', async () => {
expect(targetCall.exitCode, formatOutput(targetCall)).toBe(0);
const { host } = new URL(targetCall.stdout);
await disableSSO(host, false);
const response = await fetch(`https://${host}`);
expect(response.status).toBe(200);
expect(await response.text()).toBe(`${value}\n`);
@@ -341,7 +337,6 @@ test('ignore files specified in .nowignore', async () => {
});
const { host } = new URL(targetCall.stdout);
await disableSSO(host, false);
const ignoredFile = await fetch(`https://${host}/ignored.txt`);
expect(ignoredFile.status).toBe(404);
@@ -358,7 +353,6 @@ test('ignore files specified in .nowignore via allowlist', async () => {
});
const { host } = new URL(targetCall.stdout);
await disableSSO(host, false);
const ignoredFile = await fetch(`https://${host}/ignored.txt`);
expect(ignoredFile.status).toBe(404);
@@ -555,7 +549,6 @@ test('ensure we render a warning for deployments with no files', async () => {
// Ensure the exit code is right
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
await disableSSO(host, false);
// Send a test request to the deployment
const res = await fetch(href);
@@ -907,7 +900,6 @@ test('try to revert a deployment and assign the automatic aliases', async () =>
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
await disableSSO(deploymentUrl, false);
await waitForDeployment(deploymentUrl);
await sleep(20000);
@@ -922,7 +914,6 @@ test('try to revert a deployment and assign the automatic aliases', async () =>
'--yes',
]);
const deploymentUrl = stdout;
await disableSSO(deploymentUrl, false);
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
@@ -942,7 +933,6 @@ test('try to revert a deployment and assign the automatic aliases', async () =>
'--yes',
]);
const deploymentUrl = stdout;
await disableSSO(deploymentUrl, false);
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
@@ -1214,7 +1204,6 @@ test('deploy a Lambda with 128MB of memory', async () => {
expect(output.exitCode, formatOutput(output)).toBe(0);
const { host: url } = new URL(output.stdout);
await disableSSO(url, false);
const response = await fetch('https://' + url + '/api/memory');
expect(response.status).toBe(200);
@@ -1241,7 +1230,6 @@ test('deploy a Lambda with 3 seconds of maxDuration', async () => {
expect(output.exitCode, formatOutput(output)).toBe(0);
const url = new URL(output.stdout);
await disableSSO(url.host, false);
// Should time out
url.pathname = '/api/wait-for/5';
@@ -1280,7 +1268,6 @@ test('deploy a Lambda with a specific runtime', async () => {
expect(output.exitCode, formatOutput(output)).toBe(0);
const url = new URL(output.stdout);
await disableSSO(url.host, false);
const res = await fetch(`${url}/api/test`);
const text = await res.text();
expect(text).toBe('Hello from PHP');
@@ -1311,7 +1298,6 @@ test('use build-env', async () => {
// Test if the output is really a URL
const deploymentUrl = pickUrl(stdout);
const { href } = new URL(deploymentUrl);
await disableSSO(deploymentUrl, false);
await waitForDeployment(href);