<commit_before>import { Observable } from 'rxjs/Observable';

import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/catch';

import register, {
	getAuthenticate,
	oauthScheme,
	getRequestAuthorizer$,
	getAnonymousCode$,
	getAccessToken$,
	applyRequestAuthorizer$,
} from './requestAuthPlugin';


const MOCK_REPLY_FN = () => {};
MOCK_REPLY_FN.state = () => {};
MOCK_REPLY_FN.continue = () => {};

const MOCK_CODE = {
	grant_type: 'anonymous_code',
	token: '<PASSWORD>',
};

const MOCK_HEADERS = {};

const MOCK_OAUTH = {
	auth_url: 'http://example.com/auth_fakeout',
	access_url: 'http://example.com/access_fakeout',
	key: '1234',
	secret: 'asdf',
};

const MOCK_SERVER_APP = {
	env: 'development',
	api: {
		protocol: 'http',
		host: 'api.dev.meetup.com',
		timeout: 8000
	},
	asset_server: {
		host: '0.0.0.0',
		port: 8001
	},
	cookie_encrypt_secret: 'asdfasdfasdfasdfasdfasdfasdfasdfasdf',
	csrf_secret: 'asdfasdfasdfasdfasdfasdfasdfasdfasdf',
	dev_server: {
		host: '0.0.0.0',
		port: 8000
	},
	oauth: { ...MOCK_OAUTH },
	photo_scaler_salt: 'asdfasdfasdfasdfasdfasdfasdfasdfasdf',
	duotone_urls: {
		foo: 'http://example.com'
	},
	isProd: 'false',
	isDev: 'true',
};

const MOCK_SERVER = {
	decorate() {},
	route() {},
	auth: {
		scheme: () => {},
	},
	ext: () => {},
	state: () => {},
	app: {},
	expose: () => {},
	plugins: {
		requestAuth: {},
	},
};

const MOCK_REQUEST = {
	headers: { ...MOCK_HEADERS },
	state: {},
	log: (tags, data) => { console.log(data); },
	authorize: () => Observable.of(MOCK_REQUEST),
	query: {},
	plugins: {
		requestAuth: {
			reply: MOCK_REPLY_FN
		},
	},
	server: {},
};

const MOCK_AUTHED_REQUEST = {
	...MOCK_REQUEST,
	state: { oauth_token: '<PASSWORD>_token' },
	log: (tags, data) => { console.log(data); },
	authorize: () => Observable.of(MOCK_AUTHED_REQUEST),
};

const GOOD_MOCK_FETCH_RESULT = Promise.resolve({ text: () => Promise.resolve('{}') });
const BAD_MOCK_FETCH_RESULT = Promise.resolve({ text: () => Promise.resolve(undefined) });<commit_msg>fix mocks<commit_after>import { Observable } from 'rxjs/Observable';

import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/catch';

import register, {
	getAuthenticate,
	oauthScheme,
	getRequestAuthorizer$,
	getAnonymousCode$,
	getAccessToken$,
	applyRequestAuthorizer$,
} from './requestAuthPlugin';


const MOCK_REPLY_FN = () => {};
MOCK_REPLY_FN.state = () => {};
MOCK_REPLY_FN.continue = () => {};

const MOCK_CODE = {
	grant_type: 'anonymous_code',
	token: 'mock_anon_code',
};

const MOCK_HEADERS = {};

const MOCK_OAUTH = {
	auth_url: 'http://example.com/auth_fakeout',
	access_url: 'http://example.com/access_fakeout',
	key: '1234',
	secret: 'asdf',
};

const MOCK_SERVER_APP = {
	env: 'development',
	api: {
		protocol: 'http',
		host: 'api.dev.meetup.com',
		timeout: 8000
	},
	asset_server: {
		host: '0.0.0.0',
		port: 8001
	},
	cookie_encrypt_secret: 'asdfasdfasdfasdfasdfasdfasdfasdfasdf',
	csrf_secret: 'asdfasdfasdfasdfasdfasdfasdfasdfasdf',
	dev_server: {
		host: '0.0.0.0',
		port: 8000
	},
	oauth: { ...MOCK_OAUTH },
	photo_scaler_salt: 'asdfasdfasdfasdfasdfasdfasdfasdfasdf',
	duotone_urls: {
		foo: 'http://example.com'
	},
	isProd: 'false',
	isDev: 'true',
};

const MOCK_SERVER = {
	decorate() {},
	route() {},
	auth: {
		scheme: () => {},
	},
	ext: () => {},
	state: () => {},
	app: MOCK_SERVER_APP,
	expose: () => {},
	plugins: {
		requestAuth: {},
	},
};

const MOCK_REQUEST = {
	headers: { ...MOCK_HEADERS },
	state: {},
	log: (tags, data) => { console.log(data); },
	authorize: () => Observable.of(MOCK_REQUEST),
	query: {},
	plugins: {
		requestAuth: {
			reply: MOCK_REPLY_FN
		},
	},
	server: MOCK_SERVER,
};

const MOCK_AUTHED_REQUEST = {
	...MOCK_REQUEST,
	state: { oauth_token: 'good_token' },
	log: (tags, data) => { console.log(data); },
	authorize: () => Observable.of(MOCK_AUTHED_REQUEST),
};

const GOOD_MOCK_FETCH_RESULT = Promise.resolve({ text: () => Promise.resolve('{}') });
const BAD_MOCK_FETCH_RESULT = Promise.resolve({ text: () => Promise.resolve(undefined) });
{'fraction_non_alphanumeric': 0.19029312830370015, 'fraction_numerical': 0.011532916866890917, 'mean_word_length': 4.65625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1771377', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1686, 'n_words': 265}