Advancements with postgres (#2510)

* Start DB runner from tests

* Connect GridstoreAdapter only when needed

* removes unused package

* better test errors reporting

* Adds support for __op.Delete

* Better test error reporting

* Makes sure all tests can run without crashing

* Use xdescribe to skip test suite

* Removes unused dependencies

* Let volatiles classes be created with PG on start

* Do not fail if class dont exist

* adds index.spec.js to the pg suite

* Use a new config each test to prevent side effects

* Enable EmailVerificationToken specs with pg

* Makes sure failure output is not cut

* Reduces number of ignored tests in ParseObject.spec

* Inspect reconfiguration errors

* Mark GlobalConfig is incompatible with PG

- Problem is with nested updates (param.prop = value)

* PG: Nested JSON queries and updates

- Adds support for nested json and . operator queries
- Adds debug support for PG adapter
- Adds loglevel support in helper

* Enable working specs in ParseUser

* Sets default logLevel in tests to undefined

* Adds File type support, retores purchaseValidation specs

* Adds support for updating jsonb objects

- Restores PushController tests

* Proper implementation of deleteByQuery and ORs

- Adds ParseInstallation spec to the test suite

* xit only failing tests

* Nit on ParseAPI spec

* add sorting operator

* properly bound order keys

* reverts describe_only_db behavior

* Enables passing tests

* Adds basic support for relations, upsertOneObject aliased to createObject

* progress on queries options

* Fix ACL update related problems

* Creates relation tables on class creation

* Adds Relation tests

* remove flaky tests

* use promises instead of CB

* disable flaky test

* nits

* Fixes on schema spec

- Next thing is to implemenet geopoint and files correctly

* fix failues

* Basic GeoPoint support

* Adds support for $nearSphere/$maxDistance geopoint queries

* enable passing tests

* drop tables afterEach for PG, clean up relation tables too

* Better initialization/dropTables
This commit is contained in:
Florent Vilmart
2016-08-15 16:48:39 -04:00
committed by GitHub
parent 2f1ee2186b
commit c0249283ac
42 changed files with 1447 additions and 716 deletions

View File

@@ -2,11 +2,11 @@
const MockEmailAdapterWithOptions = require('./MockEmailAdapterWithOptions');
const request = require('request');
const MongoClient = require("mongodb").MongoClient;
const Config = require('../src/Config');
describe("Email Verification Token Expiration: ", () => {
it_exclude_dbs(['postgres'])('show the invalid link page, if the user clicks on the verify email link after the email verify token expires', done => {
it('show the invalid link page, if the user clicks on the verify email link after the email verify token expires', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -41,10 +41,13 @@ describe("Email Verification Token Expiration: ", () => {
done();
});
}, 1000);
}).catch((err) => {
jfail(err);
done();
});
});
it_exclude_dbs(['postgres'])('emailVerified should set to false, if the user does not verify their email before the email verify token expires', done => {
it('emailVerified should set to false, if the user does not verify their email before the email verify token expires', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -81,15 +84,18 @@ describe("Email Verification Token Expiration: ", () => {
done();
})
.catch((err) => {
fail("this should not fail");
jfail(error);
done();
});
});
}, 1000);
}).catch((err) => {
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('if user clicks on the email verify link before email verification token expiration then show the verify email success page', done => {
it('if user clicks on the email verify link before email verification token expiration then show the verify email success page', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -119,10 +125,13 @@ describe("Email Verification Token Expiration: ", () => {
expect(response.body).toEqual('Found. Redirecting to http://localhost:8378/1/apps/verify_email_success.html?username=testEmailVerifyTokenValidity');
done();
});
}).catch((err) => {
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('if user clicks on the email verify link before email verification token expiration then emailVerified should be true', done => {
it('if user clicks on the email verify link before email verification token expiration then emailVerified should be true', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -155,14 +164,17 @@ describe("Email Verification Token Expiration: ", () => {
done();
})
.catch((err) => {
fail("this should not fail");
jfail(error);
done();
});
});
}).catch((err) => {
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('if user clicks on the email verify link before email verification token expiration then user should be able to login', done => {
it('if user clicks on the email verify link before email verification token expiration then user should be able to login', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -196,14 +208,17 @@ describe("Email Verification Token Expiration: ", () => {
done();
})
.catch((error) => {
fail('login should have succeeded');
jfail(error);
done();
});
});
}).catch((err) => {
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('sets the _email_verify_token_expires_at and _email_verify_token fields after user SignUp', done => {
it('sets the _email_verify_token_expires_at and _email_verify_token fields after user SignUp', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -227,14 +242,12 @@ describe("Email Verification Token Expiration: ", () => {
return user.signUp();
})
.then(() => {
const databaseURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
return MongoClient.connect(databaseURI);
let config = new Config('test');
return config.database.find('_User', {username: 'sets_email_verify_token_expires_at'});
})
.then(database => {
expect(typeof database).toBe('object');
return database.collection('test__User').findOne({username: 'sets_email_verify_token_expires_at'});
})
.then(user => {
.then(results => {
expect(results.length).toBe(1);
let user = results[0];
expect(typeof user).toBe('object');
expect(user.emailVerified).toEqual(false);
expect(typeof user._email_verify_token).toBe('string');
@@ -242,12 +255,12 @@ describe("Email Verification Token Expiration: ", () => {
done();
})
.catch(error => {
fail("this should not fail");
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('unsets the _email_verify_token_expires_at and _email_verify_token fields in the User class if email verification is successful', done => {
it('unsets the _email_verify_token_expires_at and _email_verify_token fields in the User class if email verification is successful', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -275,12 +288,10 @@ describe("Email Verification Token Expiration: ", () => {
followRedirect: false,
}, (error, response, body) => {
expect(response.statusCode).toEqual(302);
const databaseURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
MongoClient.connect(databaseURI)
.then(database => {
expect(typeof database).toBe('object');
return database.collection('test__User').findOne({username: 'unsets_email_verify_token_expires_at'});
let config = new Config('test');
return config.database.find('_User', {username: 'unsets_email_verify_token_expires_at'}).then((results) => {
expect(results.length).toBe(1);
return results[0];
})
.then(user => {
expect(typeof user).toBe('object');
@@ -290,18 +301,18 @@ describe("Email Verification Token Expiration: ", () => {
done();
})
.catch(error => {
fail("this should not fail");
jfail(error);
done();
});
});
})
.catch(error => {
fail("this should not fail");
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('clicking on the email verify link by an email VERIFIED user that was setup before enabling the expire email verify token should show an invalid link', done => {
it('clicking on the email verify link by an email VERIFIED user that was setup before enabling the expire email verify token should show an invalid link', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -352,12 +363,12 @@ describe("Email Verification Token Expiration: ", () => {
});
})
.catch((err) => {
fail("this should not fail");
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('clicking on the email verify link by an email UNVERIFIED user that was setup before enabling the expire email verify token should show an invalid link', done => {
it('clicking on the email verify link by an email UNVERIFIED user that was setup before enabling the expire email verify token should show an invalid link', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -402,14 +413,13 @@ describe("Email Verification Token Expiration: ", () => {
});
})
.catch((err) => {
fail("this should not fail");
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('setting the email on the user should set a new email verification token and new expiration date for the token when expire email verify token flag is set', done => {
it('setting the email on the user should set a new email verification token and new expiration date for the token when expire email verify token flag is set', done => {
const databaseURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
let db;
let user = new Parse.User();
@@ -439,12 +449,10 @@ describe("Email Verification Token Expiration: ", () => {
return user.signUp();
})
.then(() => {
return MongoClient.connect(databaseURI);
})
.then(database => {
expect(typeof database).toBe('object');
db = database; //save the db object for later use
return db.collection('test__User').findOne({username: 'newEmailVerifyTokenOnEmailReset'});
let config = new Config('test');
return config.database.find('_User', {username: 'newEmailVerifyTokenOnEmailReset'}).then((results) => {
return results[0];
});
})
.then(userFromDb => {
expect(typeof userFromDb).toBe('object');
@@ -458,8 +466,10 @@ describe("Email Verification Token Expiration: ", () => {
});
})
.then(() => {
// get user data after email reset and new token generation
return db.collection('test__User').findOne({username: 'newEmailVerifyTokenOnEmailReset'});
let config = new Config('test');
return config.database.find('_User', {username: 'newEmailVerifyTokenOnEmailReset'}).then((results) => {
return results[0];
});
})
.then(userAfterEmailReset => {
expect(typeof userAfterEmailReset).toBe('object');
@@ -468,12 +478,12 @@ describe("Email Verification Token Expiration: ", () => {
done();
})
.catch((err) => {
fail("this should not fail");
jfail(error);
done();
});
});
it_exclude_dbs(['postgres'])('client should not see the _email_verify_token_expires_at field', done => {
it('client should not see the _email_verify_token_expires_at field', done => {
var user = new Parse.User();
var sendEmailOptions;
var emailAdapter = {
@@ -505,10 +515,13 @@ describe("Email Verification Token Expiration: ", () => {
done();
})
.catch(error => {
fail("this should not fail");
jfail(error);
done();
});
}).catch((err) => {
jfail(error);
done();
});
});