Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as uuidv4 from "uuid/v4";
import { connect } from "react-redux";
import { compose, lifecycle } from "recompose";
import { Polly } from "@pollyjs/core";
import FetchAdapter, {
HttpRequest,
HttpResponse
} from "@pollyjs/adapter-fetch";
// Register the fetch adapter so its accessible by all future polly instances
Polly.register(FetchAdapter);
import * as JsSearch from "js-search";
import {
findItem,
addItemsToTree,
findByUuids,
deleteItemsFromTree,
iterateNodes
} from "../treeUtils";
import { GlobalStoreState } from "../../startup/reducers";
import { actionCreators as fetchActionCreators } from "../fetchTracker.redux";
import withConfig from "../../startup/withConfig";
import { Config } from "../../startup/config";
import { DocRefTypeList } from "../../components/DocRefTypes/redux";
import {
PipelineModelType,
ElementDefinitions,
ElementPropertiesByElementIdType,
Dictionary,
DataSourceType,
StreamTaskType,
User
} from "../../types";
import { StreamAttributeMapResult } from "../../sections/DataViewer/types";
import { DocRefTypeList } from "../../components/DocRefTypes/redux";
import { GlobalStoreState } from "../../startup/reducers";
const { resetAllUrls } = fetchActionCreators;
// Register the fetch adapter so its accessible by all future polly instances
Polly.register(FetchAdapter);
// Whats this?
// export const DevServerDecorator = (storyFn: RenderFunction) => (
// {storyFn()}
// );
const testConfig: Config = {
authenticationServiceUrl: "/authService/authentication/v1",
authorisationServiceUrl: "/api/authorisation/v1",
stroomBaseServiceUrl: "http://localhost:9001/api",
authUsersUiUrl:
"auth/users/because/they/are/loaded/in/an/iframe/which/is/beyond/scope/of/these/tests",
authTokensUiUrl:
"auth/tokens/because/they/are/loaded/in/an/iframe/which/is/beyond/scope/of/these/tests",
advertisedUrl: "/",
appClientId: "stroom-ui"
const path = require('path');
const puppeteer = require('puppeteer');
const { Polly } = require('@pollyjs/core');
const PuppeteerAdapter = require('@pollyjs/adapter-puppeteer');
const FSPersister = require('@pollyjs/persister-fs');
Polly.register(PuppeteerAdapter);
Polly.register(FSPersister);
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.setRequestInterception(true);
const polly = new Polly('puppeteer', {
adapters: ['puppeteer'],
adapterOptions: { puppeteer: { page } },
persister: 'fs',
persisterOptions: {
fs: {
recordingsDir: path.join(__dirname, 'recordings')
}
}
import { Polly } from '@pollyjs/core';
import XHRAdapter from '@pollyjs/adapter-xhr';
import FetchAdapter from '@pollyjs/adapter-fetch';
import getDefinedRoute from './routeMatching';
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
export default function httpMockApi(routes, baseUri, options = {}) {
const polly = new Polly('Faked HTTP', {
adapters: ['xhr', 'fetch'],
recordIfMissing: false,
mode: 'passthrough',
});
const { server } = polly;
const normalizedBasedUri = baseUri.endsWith('/')
? baseUri.slice(0, -1)
: baseUri;
//Polly doesn't support intercept on .any(), so we have to run it on each method separately.
const handler = (req, res, interceptor) =>
handleIntercept(req, res, interceptor, routes, normalizedBasedUri, options);
import {TokenDecoder, AUTH_TOKEN_NAME} from './auth-token/public-api';
import {ApiErrorsInterceptor} from './api-http/interceptors/api-errors/api-errors.interceptor';
import {
API_HTTP_INTERCEPTORS,
API_HTTP_BASE_URL,
API_HTTP_DEFAULT_HEADERS,
API_HTTP_AUTHORIZATION_HEADER_NAME
} from './api-http/public-api';
import {HttpErrorResponse} from '@angular/common/http';
/*
Register the adapters and persisters we want to use. This way all future
polly instances can access them by name.
*/
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
describe('ngx-api-utils package', () => {
const apiUtilsConfig = {
baseUrl: 'http://example.com/api',
authTokenName: 'id_token',
defaultHeaders: {
accept: 'application/json, */*',
'X-Client': 'Ngx Api Utils Client'
},
authorizationHeaderName: 'Authorization'
};
let polly: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [NgxApiUtilsModule],
import { Polly } from '@pollyjs/core';
import XHRAdapter from '@pollyjs/adapter-xhr';
import FetchAdapter from '@pollyjs/adapter-fetch';
import getDefinedRoute from './routeMatching';
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
export default function httpMockApi(routes, baseUri, options = {}) {
const polly = new Polly('Faked HTTP', {
adapters: ['xhr', 'fetch'],
recordIfMissing: false,
mode: 'passthrough',
});
const { server } = polly;
const normalizedBasedUri = baseUri.endsWith('/')
? baseUri.slice(0, -1)
: baseUri;
//Polly doesn't support intercept on .any(), so we have to run it on each method separately.
const handler = (req, res, interceptor) =>
import { Polly } from '@pollyjs/core';
import XHRAdapter from '@pollyjs/adapter-xhr';
import FetchAdapter from '@pollyjs/adapter-fetch';
import RESTPersister from '@pollyjs/persister-rest';
import LocalStoragePersister from '@pollyjs/persister-local-storage';
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
Polly.register(RESTPersister);
Polly.register(LocalStoragePersister);
Polly.on('create', polly => {
polly.configure({
adapters: ['xhr', 'fetch'],
persister: 'rest',
/**
* @pollyjs/ember mounts the express middleware onto to the running
* testem and ember-cli express server and a relative host (an empty `host`)
* is preferred here. Can be overridden at runtime in cases where the
* Polly server is externally hosted.
*/
persisterOptions: { rest: { host: '' } }
});
});
import { Polly } from '@pollyjs/core';
import XHRAdapter from '@pollyjs/adapter-xhr';
import FetchAdapter from '@pollyjs/adapter-fetch';
import RESTPersister from '@pollyjs/persister-rest';
import LocalStoragePersister from '@pollyjs/persister-local-storage';
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
Polly.register(RESTPersister);
Polly.register(LocalStoragePersister);
Polly.on('create', polly => {
polly.configure({
adapters: ['xhr', 'fetch'],
persister: 'rest',
/**
* @pollyjs/ember mounts the express middleware onto to the running
* testem and ember-cli express server and a relative host (an empty `host`)
* is preferred here. Can be overridden at runtime in cases where the
* Polly server is externally hosted.
*/
persisterOptions: { rest: { host: '' } }
});
import { Polly } from '@pollyjs/core';
import XHRAdapter from '@pollyjs/adapter-xhr';
import FetchAdapter from '@pollyjs/adapter-fetch';
import RESTPersister from '@pollyjs/persister-rest';
import LocalStoragePersister from '@pollyjs/persister-local-storage';
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
Polly.register(RESTPersister);
Polly.register(LocalStoragePersister);
Polly.on('create', polly => {
polly.configure({
adapters: ['xhr', 'fetch'],
persister: 'rest',
/**
* @pollyjs/ember mounts the express middleware onto to the running
* testem and ember-cli express server and a relative host (an empty `host`)
* is preferred here. Can be overridden at runtime in cases where the
* Polly server is externally hosted.
*/
persisterOptions: { rest: { host: '' } }
});
});
import * as FetchAdapter from '@pollyjs/adapter-fetch';
import {TokenDecoder, AUTH_TOKEN_NAME} from './auth-token/public-api';
import {ApiErrorsInterceptor} from './api-http/interceptors/api-errors/api-errors.interceptor';
import {
API_HTTP_INTERCEPTORS,
API_HTTP_BASE_URL,
API_HTTP_DEFAULT_HEADERS,
API_HTTP_AUTHORIZATION_HEADER_NAME
} from './api-http/public-api';
import {HttpErrorResponse} from '@angular/common/http';
/*
Register the adapters and persisters we want to use. This way all future
polly instances can access them by name.
*/
Polly.register(XHRAdapter);
Polly.register(FetchAdapter);
describe('ngx-api-utils package', () => {
const apiUtilsConfig = {
baseUrl: 'http://example.com/api',
authTokenName: 'id_token',
defaultHeaders: {
accept: 'application/json, */*',
'X-Client': 'Ngx Api Utils Client'
},
authorizationHeaderName: 'Authorization'
};
let polly: any;
beforeEach(() => {
TestBed.configureTestingModule({