Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes deprecated request and @percy/agent #1113

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
"**/prismjs": "^1.23.0",
"**/react-syntax-highlighter": "^15.3.1",
"**/react-syntax-highlighter/**/highlight.js": "^10.4.1",
"**/request": "^2.88.2",
"**/ssri": "^6.0.2",
"**/tar": "^6.1.11",
"**/trim": "^0.0.3",
Expand Down Expand Up @@ -199,7 +198,6 @@
"react-use": "^13.27.0",
"redux-thunk": "^2.3.0",
"regenerator-runtime": "^0.13.3",
"request": "^2.88.0",
"require-in-the-middle": "^5.0.2",
"rison-node": "1.0.2",
"rxjs": "^6.5.5",
Expand Down Expand Up @@ -245,7 +243,8 @@
"@osd/test": "1.0.0",
"@osd/test-subj-selector": "0.2.1",
"@osd/utility-types": "1.0.0",
"@percy/agent": "^0.28.6",
"@percy/cli": "^1.0.0-beta.74",
"@percy/sdk-utils": "^1.0.0-beta.74",
"@testing-library/dom": "^7.24.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.0.4",
Expand Down Expand Up @@ -313,7 +312,6 @@
"@types/react-router-dom": "^5.3.2",
"@types/react-virtualized": "^9.18.7",
"@types/recompose": "^0.30.6",
"@types/request": "^2.48.2",
"@types/selenium-webdriver": "^4.0.9",
"@types/semver": "^5.5.0",
"@types/sinon": "^7.0.13",
Expand All @@ -325,6 +323,7 @@
"@types/tar": "^4.0.3",
"@types/testing-library__jest-dom": "^5.9.3",
"@types/testing-library__react-hooks": "^3.4.0",
"@types/tough-cookie": "^4.0.1",
"@types/type-detect": "^4.0.1",
"@types/uuid": "^3.4.4",
"@types/vinyl": "^2.0.4",
Expand Down Expand Up @@ -406,7 +405,7 @@
"leaflet-responsive-popup": "0.6.4",
"leaflet-vega": "^0.8.6",
"leaflet.heat": "0.2.0",
"less": "npm:@elastic/less@2.7.3-kibana",
"less": "^4.1.2",
"license-checker": "^16.0.0",
"listr": "^0.14.1",
"load-grunt-config": "^3.0.1",
Expand Down Expand Up @@ -450,6 +449,7 @@
"supertest-as-promised": "^4.0.2",
"tape": "^5.0.1",
"topojson-client": "3.0.0",
"tough-cookie": "^4.0.0",
"tree-kill": "^1.2.2",
"typescript": "4.0.2",
"ui-select": "0.19.8",
Expand Down
175 changes: 0 additions & 175 deletions packages/osd-test/src/functional_tests/lib/auth.js

This file was deleted.

23 changes: 1 addition & 22 deletions packages/osd-test/src/functional_tests/lib/run_opensearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ import { resolve } from 'path';
import { OPENSEARCH_DASHBOARDS_ROOT } from './paths';
import { createLegacyOpenSearchTestCluster } from '../../legacy_opensearch';

import { setupUsers, DEFAULT_SUPERUSER_PASS } from './auth';

export async function runOpenSearch({ config, options }) {
const { log, opensearchFrom } = options;
const ssl = config.get('opensearchTestCluster.ssl');
Expand All @@ -51,9 +49,7 @@ export async function runOpenSearch({ config, options }) {

const cluster = createLegacyOpenSearchTestCluster({
port: config.get('servers.opensearch.port'),
password: isSecurityEnabled
? DEFAULT_SUPERUSER_PASS
: config.get('servers.opensearch.password'),
password: isSecurityEnabled ? 'changethispassword' : config.get('servers.opensearch.password'),
license,
log,
basePath: resolve(OPENSEARCH_DASHBOARDS_ROOT, '.opensearch'),
Expand All @@ -66,22 +62,5 @@ export async function runOpenSearch({ config, options }) {

await cluster.start();

if (isSecurityEnabled) {
await setupUsers({
log,
opensearchPort: config.get('servers.opensearch.port'),
updates: [config.get('servers.opensearch'), config.get('servers.opensearchDashboards')],
protocol: config.get('servers.opensearch').protocol,
caPath: getRelativeCertificateAuthorityPath(config.get('osdTestServer.serverArgs')),
});
}

return cluster;
}

function getRelativeCertificateAuthorityPath(opensearchConfig = []) {
const caConfig = opensearchConfig.find(
(config) => config.indexOf('--opensearch.ssl.certificateAuthorities') === 0
);
return caConfig ? caConfig.split('=')[1] : undefined;
}
3 changes: 0 additions & 3 deletions packages/osd-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export {
adminTestUser,
} from './osd';

// @ts-ignore not typed yet
export { setupUsers, DEFAULT_SUPERUSER_PASS } from './functional_tests/lib/auth';

export { readConfigFile } from './functional_test_runner/lib/config/read_config_file';

export { runFtrCli } from './functional_test_runner/cli';
Expand Down
7 changes: 4 additions & 3 deletions src/core/server/http/cookie_session_storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
import request from 'request';

import { parse as parseCookie } from 'tough-cookie';
import supertest from 'supertest';
import { REPO_ROOT } from '@osd/dev-utils';
import { ByteSizeValue } from '@osd/config-schema';
Expand Down Expand Up @@ -107,7 +108,7 @@ interface Storage {
}

function retrieveSessionCookie(cookies: string) {
const sessionCookie = request.cookie(cookies);
const sessionCookie = parseCookie(cookies);
if (!sessionCookie) {
throw new Error('session cookie expected to be defined');
}
Expand Down Expand Up @@ -487,7 +488,7 @@ describe('Cookie based SessionStorage', () => {
expect(cookies).toHaveLength(1);

const sessionCookie = retrieveSessionCookie(cookies[0]);
expect(sessionCookie.extensions).toContain(`SameSite=${sameSite}`);
expect(sessionCookie.sameSite).toEqual(sameSite.toLowerCase());

await supertest(innerServer.listener)
.get('/')
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/http/integration_tests/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

import supertest from 'supertest';
import request from 'request';
import { parse as parseCookie } from 'tough-cookie';
import { schema } from '@osd/config-schema';

import { ensureRawRequest } from '../router';
Expand Down Expand Up @@ -774,7 +774,7 @@ describe('Auth', () => {
const cookies = response.header['set-cookie'];
expect(cookies).toHaveLength(1);

const sessionCookie = request.cookie(cookies[0]);
const sessionCookie = parseCookie(cookies[0]);
if (!sessionCookie) {
throw new Error('session cookie expected to be defined');
}
Expand Down
18 changes: 1 addition & 17 deletions src/core/test_helpers/osd_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ import { Client } from 'elasticsearch';
import { ToolingLog, REPO_ROOT } from '@osd/dev-utils';
import {
createLegacyOpenSearchTestCluster,
DEFAULT_SUPERUSER_PASS,
opensearchTestConfig,
osdTestConfig,
opensearchDashboardsServerTestUser,
opensearchDashboardsTestUser,
setupUsers,
} from '@osd/test';
import { defaultsDeep, get } from 'lodash';
import { resolve } from 'path';
Expand Down Expand Up @@ -253,7 +250,6 @@ export function createTestServers({
defaultsDeep({}, get(settings, 'opensearch', {}), {
log,
license,
password: license === 'trial' ? DEFAULT_SUPERUSER_PASS : undefined,
})
);

Expand All @@ -269,19 +265,7 @@ export function createTestServers({
await opensearch.start(get(settings, 'opensearch.opensearchArgs', []));

if (['gold', 'trial'].includes(license)) {
await setupUsers({
log,
opensearchPort: opensearchTestConfig.getUrlParts().port,
updates: [
...usersToBeAdded,
// user opensearch
opensearchTestConfig.getUrlParts(),
// user opensearchDashboards
osdTestConfig.getUrlParts(),
],
});

// Override provided configs, we know what the opensearch user is now
// Override provided configs
osdSettings.opensearch = {
hosts: [opensearchTestConfig.getUrl()],
username: opensearchDashboardsServerTestUser.username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
* GitHub history for details.
*/

import { readFileSync } from 'fs';
import { agentJsFilename } from '@percy/agent/dist/utils/sdk-utils';

export function takePercySnapshot(show, hide) {
if (!window.PercyAgent) {
return false;
Expand Down Expand Up @@ -120,7 +117,5 @@ export function takePercySnapshot(show, hide) {
}

export const takePercySnapshotWithAgent = `
${readFileSync(agentJsFilename(), 'utf8')}

return (${takePercySnapshot.toString()}).apply(null, arguments);
`;
Loading