Skip to content

Postgres: Operations, Hooks, OAuth login, Files support #2528

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 16 commits into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"mongodb": "2.2.5",
"multer": "1.2.0",
"parse": "1.9.1",
"parse-server-fs-adapter": "1.0.0",
"parse-server-fs-adapter": "1.0.1",
"parse-server-push-adapter": "1.0.4",
"parse-server-s3-adapter": "1.0.4",
"parse-server-simple-mailgun-adapter": "1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe('miscellaneous', function() {
});
});

it('ensure that if you try to sign up a user with a unique username and email, but duplicates in some other field that has a uniqueness constraint, you get a regular duplicate value error', done => {
it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a unique username and email, but duplicates in some other field that has a uniqueness constraint, you get a regular duplicate value error', done => {
let config = new Config('test');
config.database.adapter.addFieldIfNotExists('_User', 'randomField', { type: 'String' })
.then(() => config.database.adapter.ensureUniqueness('_User', userSchema, ['randomField']))
Expand All @@ -233,6 +233,7 @@ describe('miscellaneous', function() {
return user.signUp()
})
.catch(error => {
console.error(error);
expect(error.code).toEqual(Parse.Error.DUPLICATE_VALUE);
done();
});
Expand Down
14 changes: 7 additions & 7 deletions spec/ParseFile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ for (var i = 0; i < str.length; i++) {
data.push(str.charCodeAt(i));
}

describe_only_db('mongo')('Parse.File testing', () => {
describe_only_db('mongo')('creating files', () => {
describe('Parse.File testing', () => {
describe('creating files', () => {
it('works with Content-Type', done => {
var headers = {
'Content-Type': 'application/octet-stream',
Expand Down Expand Up @@ -88,7 +88,7 @@ describe_only_db('mongo')('Parse.File testing', () => {
});
});

it_exclude_dbs(['postgres'])('supports REST end-to-end file create, read, delete, read', done => {
it('supports REST end-to-end file create, read, delete, read', done => {
var headers = {
'Content-Type': 'image/jpeg',
'X-Parse-Application-Id': 'test',
Expand Down Expand Up @@ -204,7 +204,7 @@ describe_only_db('mongo')('Parse.File testing', () => {
});
});

it_exclude_dbs(['postgres'])("save file", done => {
it("save file", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
file.save(expectSuccess({
Expand Down Expand Up @@ -273,7 +273,7 @@ describe_only_db('mongo')('Parse.File testing', () => {
}, done));
});

it_exclude_dbs(['postgres'])("autosave file in object", done => {
it("autosave file in object", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
var object = new Parse.Object("TestObject");
Expand Down Expand Up @@ -506,7 +506,7 @@ describe_only_db('mongo')('Parse.File testing', () => {
});
});

it_exclude_dbs(['postgres'])('creates correct url for old files hosted on files.parsetfss.com', done => {
it('creates correct url for old files hosted on files.parsetfss.com', done => {
var file = {
__type: 'File',
url: 'http://irrelevant.elephant/',
Expand All @@ -529,7 +529,7 @@ describe_only_db('mongo')('Parse.File testing', () => {
});
});

it_exclude_dbs(['postgres'])('creates correct url for old files hosted on files.parse.com', done => {
it('creates correct url for old files hosted on files.parse.com', done => {
var file = {
__type: 'File',
url: 'http://irrelevant.elephant/',
Expand Down
32 changes: 16 additions & 16 deletions spec/ParseHooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ app.use(bodyParser.json({ 'type': '*/*' }))
app.listen(12345);

describe('Hooks', () => {
it_exclude_dbs(['postgres'])("should have no hooks registered", (done) => {
it("should have no hooks registered", (done) => {
Parse.Hooks.getFunctions().then((res) => {
expect(res.constructor).toBe(Array.prototype.constructor);
done();
Expand All @@ -25,7 +25,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("should have no triggers registered", (done) => {
it("should have no triggers registered", (done) => {
Parse.Hooks.getTriggers().then( (res) => {
expect(res.constructor).toBe(Array.prototype.constructor);
done();
Expand All @@ -35,7 +35,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("should CRUD a function registration", (done) => {
it("should CRUD a function registration", (done) => {
// Create
Parse.Hooks.createFunction("My-Test-Function", "http://someurl")
.then(response => {
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Hooks', () => {
})
});

it_exclude_dbs(['postgres'])("should CRUD a trigger registration", (done) => {
it("should CRUD a trigger registration", (done) => {
// Create
Parse.Hooks.createTrigger("MyClass","beforeDelete", "http://someurl").then((res) => {
expect(res.className).toBe("MyClass");
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('Hooks', () => {
})
});

it_exclude_dbs(['postgres'])("should fail trying to create two times the same function", (done) => {
it("should fail trying to create two times the same function", (done) => {
Parse.Hooks.createFunction("my_new_function", "http://url.com").then( () => {
return Parse.Hooks.createFunction("my_new_function", "http://url.com")
}, () => {
Expand All @@ -165,7 +165,7 @@ describe('Hooks', () => {
})
});

it_exclude_dbs(['postgres'])("should fail trying to create two times the same trigger", (done) => {
it("should fail trying to create two times the same trigger", (done) => {
Parse.Hooks.createTrigger("MyClass", "beforeSave", "http://url.com").then( () => {
return Parse.Hooks.createTrigger("MyClass", "beforeSave", "http://url.com")
}, () => {
Expand All @@ -188,7 +188,7 @@ describe('Hooks', () => {
})
});

it_exclude_dbs(['postgres'])("should fail trying to update a function that don't exist", (done) => {
it("should fail trying to update a function that don't exist", (done) => {
Parse.Hooks.updateFunction("A_COOL_FUNCTION", "http://url.com").then( () => {
fail("Should not succeed")
}, (err) => {
Expand All @@ -213,7 +213,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("should fail trying to update a trigger that don't exist", (done) => {
it("should fail trying to update a trigger that don't exist", (done) => {
Parse.Hooks.updateTrigger("AClassName","beforeSave", "http://url.com").then( () => {
fail("Should not succeed")
}, (err) => {
Expand Down Expand Up @@ -269,7 +269,7 @@ describe('Hooks', () => {
});


it_exclude_dbs(['postgres'])("should create hooks and properly preload them", (done) => {
it("should create hooks and properly preload them", (done) => {

var promises = [];
for (var i = 0; i<5; i++) {
Expand Down Expand Up @@ -304,7 +304,7 @@ describe('Hooks', () => {
})
});

it_exclude_dbs(['postgres'])("should run the function on the test server", (done) => {
it("should run the function on the test server", (done) => {

app.post("/SomeFunction", function(req, res) {
res.json({success:"OK!"});
Expand All @@ -326,7 +326,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("should run the function on the test server", (done) => {
it("should run the function on the test server", (done) => {

app.post("/SomeFunctionError", function(req, res) {
res.json({error: {code: 1337, error: "hacking that one!"}});
Expand All @@ -353,7 +353,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("should provide X-Parse-Webhook-Key when defined", (done) => {
it("should provide X-Parse-Webhook-Key when defined", (done) => {
app.post("/ExpectingKey", function(req, res) {
if (req.get('X-Parse-Webhook-Key') === 'hook') {
res.json({success: "correct key provided"});
Expand All @@ -378,7 +378,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("should not pass X-Parse-Webhook-Key if not provided", (done) => {
it("should not pass X-Parse-Webhook-Key if not provided", (done) => {
reconfigureServer({ webhookKey: undefined })
.then(() => {
app.post("/ExpectingKeyAlso", function(req, res) {
Expand Down Expand Up @@ -411,7 +411,7 @@ describe('Hooks', () => {
});


it_exclude_dbs(['postgres'])("should run the beforeSave hook on the test server", (done) => {
it("should run the beforeSave hook on the test server", (done) => {
var triggerCount = 0;
app.post("/BeforeSaveSome", function(req, res) {
triggerCount++;
Expand All @@ -438,7 +438,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("beforeSave hooks should correctly handle responses containing entire object", (done) => {
it("beforeSave hooks should correctly handle responses containing entire object", (done) => {
app.post("/BeforeSaveSome2", function(req, res) {
var object = Parse.Object.fromJSON(req.body.object);
object.set('hello', "world");
Expand All @@ -458,7 +458,7 @@ describe('Hooks', () => {
});
});

it_exclude_dbs(['postgres'])("should run the afterSave hook on the test server", (done) => {
it("should run the afterSave hook on the test server", (done) => {
var triggerCount = 0;
var newObjectId;
app.post("/AfterSaveSome", function(req, res) {
Expand Down
4 changes: 2 additions & 2 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])("containsAll number array queries", function(done) {
it("containsAll number array queries", function(done) {
var NumberSet = Parse.Object.extend({ className: "NumberSet" });

var objectsList = [];
Expand All @@ -211,7 +211,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])("containsAll string array queries", function(done) {
it("containsAll string array queries", function(done) {
var StringSet = Parse.Object.extend({ className: "StringSet" });

var objectsList = [];
Expand Down
5 changes: 4 additions & 1 deletion spec/ParseRelation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('Parse.Relation testing', () => {
});
});

it_exclude_dbs(['postgres'])("query on pointer and relation fields with equal", (done) => {
it("query on pointer and relation fields with equal", (done) => {
var ChildObject = Parse.Object.extend("ChildObject");
var childObjects = [];
for (var i = 0; i < 10; i++) {
Expand Down Expand Up @@ -331,6 +331,9 @@ describe('Parse.Relation testing', () => {
done();
});
});
}).catch(err => {
jfail(err);
done();
});
});

Expand Down
2 changes: 1 addition & 1 deletion spec/ParseRole.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('Parse Role testing', () => {
return role.save({}, { useMasterKey: true });
};

it("should not recursively load the same role multiple times", (done) => {
it_exclude_dbs(['postgres'])("should not recursively load the same role multiple times", (done) => {
var rootRole = "RootRole";
var roleNames = ["FooRole", "BarRole", "BazRole"];
var allRoles = [rootRole].concat(roleNames);
Expand Down
4 changes: 2 additions & 2 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('Parse.User testing', () => {
})
});

it_exclude_dbs(['postgres'])("user login with files", (done) => {
it("user login with files", (done) => {
let file = new Parse.File("yolo.txt", [1,2,3], "text/plain");
file.save().then((file) => {
return Parse.User.signUp("asdf", "zxcv", { "file" : file });
Expand Down Expand Up @@ -1118,7 +1118,7 @@ describe('Parse.User testing', () => {
});
});

it_exclude_dbs(['postgres'])('log in with provider with files', done => {
it('log in with provider with files', done => {
let provider = getMockFacebookProvider();
Parse.User._registerAuthenticationProvider(provider);
let file = new Parse.File("yolo.txt", [1, 2, 3], "text/plain");
Expand Down
6 changes: 3 additions & 3 deletions spec/PurchaseValidation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("test validate_receipt endpoint", () => {
});
})

it_exclude_dbs(['postgres'])("should bypass appstore validation", (done) => {
it("should bypass appstore validation", (done) => {

request.post({
headers: {
Expand Down Expand Up @@ -170,7 +170,7 @@ describe("test validate_receipt endpoint", () => {
})
});

it_exclude_dbs(['postgres'])("should be able to update a _Product", (done) => {
it("should be able to update a _Product", (done) => {
var query = new Parse.Query("_Product");
query.first().then(function(product) {
if (!product) {
Expand All @@ -188,7 +188,7 @@ describe("test validate_receipt endpoint", () => {
});
});

it_exclude_dbs(['postgres'])("should not be able to remove a require key in a _Product", (done) => {
it("should not be able to remove a require key in a _Product", (done) => {
var query = new Parse.Query("_Product");
query.first().then(function(product){
if (!product) {
Expand Down
20 changes: 13 additions & 7 deletions spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('SchemaController', () => {
});
});

it_exclude_dbs(['postgres'])('will resolve class creation races appropriately', done => {
it('will resolve class creation races appropriately', done => {
// If two callers race to create the same schema, the response to the
// race loser should be the same as if they hadn't been racing.
config.database.loadSchema()
Expand Down Expand Up @@ -617,7 +617,7 @@ describe('SchemaController', () => {
});
});

it_exclude_dbs(['postgres'])('refuses to delete fields that dont exist', done => {
it('refuses to delete fields that dont exist', done => {
hasAllPODobject().save()
.then(() => config.database.loadSchema())
.then(schema => schema.deleteField('missingField', 'HasAllPOD'))
Expand All @@ -628,7 +628,7 @@ describe('SchemaController', () => {
});
});

it_exclude_dbs(['postgres'])('drops related collection when deleting relation field', done => {
it('drops related collection when deleting relation field', done => {
var obj1 = hasAllPODobject();
obj1.save()
.then(savedObj1 => {
Expand Down Expand Up @@ -659,7 +659,7 @@ describe('SchemaController', () => {
});
});

it_exclude_dbs(['postgres'])('can delete relation field when related _Join collection not exist', done => {
it('can delete relation field when related _Join collection not exist', done => {
config.database.loadSchema()
.then(schema => {
schema.addClassIfNotExists('NewClass', {
Expand Down Expand Up @@ -688,7 +688,13 @@ describe('SchemaController', () => {
})
.then(() => config.database.collectionExists('_Join:relationField:NewClass'))
.then(exist => {
expect(exist).toEqual(false);
on_db('postgres', () => {
// We create the table when creating the column
expect(exist).toEqual(true);
}, () => {
expect(exist).toEqual(false);
});

})
.then(() => schema.deleteField('relationField', 'NewClass', config.database))
.then(() => schema.reloadData())
Expand All @@ -705,7 +711,7 @@ describe('SchemaController', () => {
});
});

it_exclude_dbs(['postgres'])('can delete string fields and resave as number field', done => {
it('can delete string fields and resave as number field', done => {
Parse.Object.disableSingleInstance();
var obj1 = hasAllPODobject();
var obj2 = hasAllPODobject();
Expand Down Expand Up @@ -733,7 +739,7 @@ describe('SchemaController', () => {
});
});

it_exclude_dbs(['postgres'])('can delete pointer fields and resave as string', done => {
it('can delete pointer fields and resave as string', done => {
Parse.Object.disableSingleInstance();
var obj1 = new Parse.Object('NewClass');
obj1.save()
Expand Down
Loading