Skip to content

Commit

Permalink
Removes deprecated request and @percy/agent
Browse files Browse the repository at this point in the history
* Addresses first set of dependencies that are upstream from
`json-schema@0.2.3`. There is more work to do but a webpack upgrade is
required first.
* Replaces usage of `request` in integration tests with `tough-cookie`.
* `@percy/agent` is deprecated and is replaced by `@percy/cli`.
* Also removes unnecessary user management logic from functional tests.

Incremental change towards addressing opensearch-project#1066

Signed-off-by: Tommy Markley <markleyt@amazon.com>
  • Loading branch information
Tommy Markley committed Jan 7, 2022
1 parent 8b518e7 commit 2567024
Show file tree
Hide file tree
Showing 10 changed files with 592 additions and 859 deletions.
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,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 @@ -125,17 +124,17 @@
"@elastic/safer-lodash-set": "0.0.0",
"@hapi/good-squeeze": "5.2.1",
"@hapi/wreck": "^15.0.2",
"@osd/ace": "1.0.0",
"@osd/analytics": "1.0.0",
"@osd/apm-config-loader": "1.0.0",
"@osd/config": "1.0.0",
"@osd/config-schema": "1.0.0",
"@osd/i18n": "1.0.0",
"@osd/interpreter": "1.0.0",
"@osd/logging": "1.0.0",
"@osd/monaco": "1.0.0",
"@osd/std": "1.0.0",
"@osd/ui-framework": "1.0.0",
"@osd/ace": "1.0.0",
"@osd/monaco": "1.0.0",
"@osd/ui-shared-deps": "1.0.0",
"@types/yauzl": "^2.9.1",
"JSONStream": "1.3.5",
Expand Down Expand Up @@ -200,7 +199,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 @@ -230,13 +228,15 @@
"@elastic/filesaver": "1.1.2",
"@elastic/github-checks-reporter": "0.0.20b3",
"@elastic/makelogs": "^6.0.0",
"@microsoft/api-documenter": "^7.13.78",
"@microsoft/api-extractor": "^7.19.3",
"@osd/babel-preset": "1.0.0",
"@osd/dev-utils": "1.0.0",
"@osd/opensearch": "1.0.0",
"@osd/opensearch-archiver": "1.0.0",
"@osd/eslint-import-resolver-opensearch-dashboards": "2.0.0",
"@osd/eslint-plugin-eslint": "1.0.0",
"@osd/expect": "1.0.0",
"@osd/opensearch": "1.0.0",
"@osd/opensearch-archiver": "1.0.0",
"@osd/optimizer": "1.0.0",
"@osd/plugin-generator": "1.0.0",
"@osd/pm": "1.0.0",
Expand All @@ -245,9 +245,8 @@
"@osd/test": "1.0.0",
"@osd/test-subj-selector": "0.2.1",
"@osd/utility-types": "1.0.0",
"@microsoft/api-documenter": "^7.13.78",
"@microsoft/api-extractor": "^7.19.3",
"@percy/agent": "^0.28.6",
"@percy/cli": "^1.0.0-beta.71",
"@percy/sdk-utils": "^1.0.0-beta.71",
"@testing-library/dom": "^7.24.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.0.4",
Expand Down Expand Up @@ -331,6 +330,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 @@ -412,7 +412,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 @@ -456,6 +456,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
Loading

0 comments on commit 2567024

Please sign in to comment.