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

index user if not existed and log last active time for user accessing apis via backend apps #227

Merged
merged 23 commits into from
Nov 8, 2020
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
4 changes: 3 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ GITHUB_CLIENT_ID=YOUR_GITHUB_CLIENT_ID
GITHUB_SECRET=YOUR_GITHUB_CLIENT_SECRET
GITHUB_CALLBACK_URL=http://localhost:5000/callback/github

#Google Analytics Related settings
# Google Analytics Related settings
GOOGLE_OAUTH_KEY_PATH=PATH_TO_SERVICE_ACCOUNT_KEY
GA_PAGE_SIZE=10000
GA_WEB_VIEW_ID=GA_WEB_VIEW_ID
Expand All @@ -64,3 +64,5 @@ URL_RESOLVER_URL=http://localhost:4000
ENGINE_API_KEY=

WEB_CONCURRENCY=2

JEST_TIMEOUT=5000
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ jspm_packages
# Optional REPL history
.node_repl_history

config/local-*

# docker-compose test data
esdata

.env
# local config
config/local-*
.vscode/
.env
241 changes: 241 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"seed": "cd test/rumors-db && npm run seed",
"pretest": "npm run rumors-db:test",
"test": "NODE_ENV=test ELASTICSEARCH_URL=http://localhost:62223 jest --runInBand",
"start": "pm2 startOrRestart ecosystem.config.js --env production --no-daemon",
"posttest": "NODE_ENV=test ELASTICSEARCH_URL=http://localhost:62223 babel-node test/postTest.js",
"start": "pm2 startOrRestart ecosystem.config.js --env production --no-daemon",
"lint": "eslint src/.",
"lint:fix": "eslint --fix src/.",
"rumors-db:pull": "cd test/rumors-db && git pull",
Expand Down Expand Up @@ -62,6 +63,7 @@
"@babel/plugin-syntax-import-meta": "^7.8.0",
"@babel/polyfill": "^7.8.0",
"@babel/preset-env": "^7.8.0",
"apollo-server-testing": "^2.18.2",
"babel-eslint": "^10.0.3",
"babel-jest": "^26.0.0",
"babel-plugin-module-resolver": "^4.0.0",
Expand All @@ -82,7 +84,8 @@
],
"setupFilesAfterEnv": [
"./test/setup.js"
]
],
"testSequencer": "./test/testSequencer.js"
},
"engines": {
"node": ">=12"
Expand Down
11 changes: 11 additions & 0 deletions src/__fixtures__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
'/users/doc/6LOqD_3gpe4ZVaxRvemf7KNTfm6y3WNBu1hbs-5MRdSWiWVss': {
name: 'test user 2',
appUserId: 'testUser2',
appId: 'TEST_BACKEND',
},
'/users/doc/testUser1': {
name: 'test user 1',
appId: 'WEBSITE',
},
};
11 changes: 8 additions & 3 deletions src/__tests__/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import MockDate from 'mockdate';
import { loadFixtures, unloadFixtures } from 'util/fixtures';
import fixtures from '../__fixtures__/auth';
import { verifyProfile } from '../auth';
import client from 'util/client';

const FIXED_DATE = 612921600000;

describe('verifyProfile', () => {
beforeEach(() => loadFixtures(fixtures));
afterEach(() => unloadFixtures(fixtures));
beforeAll(() => loadFixtures(fixtures));
afterAll(() => unloadFixtures(fixtures));

it('authenticates user via profile ID', async () => {
const passportProfile = {
Expand Down Expand Up @@ -48,7 +49,11 @@ describe('verifyProfile', () => {
'facebookId'
);
MockDate.reset();

await client.delete({
index: 'users',
type: 'doc',
id: id,
});
expect(newUser).toMatchSnapshot();
});
});
Loading