Skip to content

test: fix expired twitter auth token #1461

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

Merged
merged 3 commits into from
Mar 23, 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
24 changes: 5 additions & 19 deletions integration/test/ParseUserTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const assert = require('assert');
const Parse = require('../../node');
const uuidv4 = require('uuid/v4');
const { twitterAuthData } = require('./helper');

class CustomUser extends Parse.User {
constructor(attributes) {
Expand Down Expand Up @@ -953,21 +954,13 @@ describe('Parse User', () => {

it('can link with twitter', async () => {
Parse.User.enableUnsafeCurrentUser();
const authData = {
id: 227463280,
consumer_key: '5QiVwxr8FQHbo5CMw46Z0jquF',
consumer_secret: 'p05FDlIRAnOtqJtjIt0xcw390jCcjj56QMdE9B52iVgOEb7LuK',
auth_token: '227463280-lngpMGXdnG36JiuzGfAYbKcZUPwjmcIV2NqL9hWc',
auth_token_secret: 'G1tl1R0gaYKTyxw0uYJDKRoVhM16ifyLeMwIaKlFtPkQr',
};
const user = new Parse.User();
user.setUsername(uuidv4());
user.setPassword(uuidv4());
await user.signUp();

await user.linkWith('twitter', { authData });

expect(user.get('authData').twitter.id).toBe(authData.id);
await user.linkWith('twitter', { authData: twitterAuthData });
expect(user.get('authData').twitter.id).toBe(twitterAuthData.id);
expect(user._isLinked('twitter')).toBe(true);

await user._unlinkFrom('twitter');
Expand All @@ -977,25 +970,18 @@ describe('Parse User', () => {
it('can link with twitter and facebook', async () => {
Parse.User.enableUnsafeCurrentUser();
Parse.FacebookUtils.init();
const authData = {
id: 227463280,
consumer_key: '5QiVwxr8FQHbo5CMw46Z0jquF',
consumer_secret: 'p05FDlIRAnOtqJtjIt0xcw390jCcjj56QMdE9B52iVgOEb7LuK',
auth_token: '227463280-lngpMGXdnG36JiuzGfAYbKcZUPwjmcIV2NqL9hWc',
auth_token_secret: 'G1tl1R0gaYKTyxw0uYJDKRoVhM16ifyLeMwIaKlFtPkQr',
};
const user = new Parse.User();
user.setUsername(uuidv4());
user.setPassword(uuidv4());
await user.signUp();

await user.linkWith('twitter', { authData });
await user.linkWith('twitter', { authData: twitterAuthData });
await Parse.FacebookUtils.link(user);

expect(Parse.FacebookUtils.isLinked(user)).toBe(true);
expect(user._isLinked('twitter')).toBe(true);

expect(user.get('authData').twitter.id).toBe(authData.id);
expect(user.get('authData').twitter.id).toBe(twitterAuthData.id);
expect(user.get('authData').facebook.id).toBe('test');
});

Expand Down
22 changes: 20 additions & 2 deletions integration/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ const mountPath = '/parse';
const serverURL = 'http://localhost:1337/parse';
let didChangeConfiguration = false;

/*
To generate the auth data below, the Twitter app "GitHub CI Test App" has
been created, managed by the @ParsePlatform Twitter account. In case this
test starts to fail because the token has become invalid, generate a new
token according to the OAuth process described in the Twitter docs[1].

[1] https://developer.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens
*/
const twitterAuthData = {
id: '1506726799266430985',
consumer_key: 'jeQw6luN2PEWREtoFDb0FdGYf',
consumer_secret: 'VSFENh1X5UC4MLEuduHLtJDnf8Ydsh5KuSR4zZQufFCAGNtzcs',
auth_token: '1506726799266430985-NKM9tqVbPXMnLhHTLYB98SNGtxxi6v',
auth_token_secret: 'JpDVIINbqV5TK0th9nKiS1IVokZfjRj06FrXxCrkggF07',
};

const defaultConfiguration = {
databaseURI: 'mongodb://localhost:27017/integration',
appId: 'integration',
Expand All @@ -34,8 +50,8 @@ const defaultConfiguration = {
appIds: 'test',
},
twitter: {
consumer_key: '5QiVwxr8FQHbo5CMw46Z0jquF',
consumer_secret: 'p05FDlIRAnOtqJtjIt0xcw390jCcjj56QMdE9B52iVgOEb7LuK',
consumer_key: twitterAuthData.consumer_key,
consumer_secret: twitterAuthData.consumer_secret,
},
},
verbose: false,
Expand Down Expand Up @@ -144,3 +160,5 @@ afterEach(async () => {
await reconfigureServer();
}
});

module.exports = { twitterAuthData };