committed by
Florent Vilmart
parent
f8403943ab
commit
a103871cbc
@@ -4,7 +4,7 @@ var defaultColumns = require('../src/Controllers/SchemaController').defaultColum
|
|||||||
var authenticationLoader = require('../src/Adapters/Auth');
|
var authenticationLoader = require('../src/Adapters/Auth');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
describe('AuthenticationProviers', function() {
|
describe('AuthenticationProviders', function() {
|
||||||
["facebook", "github", "instagram", "google", "linkedin", "meetup", "twitter", "janrainengage", "janraincapture", "vkontakte"].map(function(providerName){
|
["facebook", "github", "instagram", "google", "linkedin", "meetup", "twitter", "janrainengage", "janraincapture", "vkontakte"].map(function(providerName){
|
||||||
it("Should validate structure of " + providerName, (done) => {
|
it("Should validate structure of " + providerName, (done) => {
|
||||||
var provider = require("../src/Adapters/Auth/" + providerName);
|
var provider = require("../src/Adapters/Auth/" + providerName);
|
||||||
@@ -230,10 +230,10 @@ describe('AuthenticationProviers', function() {
|
|||||||
expect(typeof validator).toBe('function');
|
expect(typeof validator).toBe('function');
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateAuthenticationHandler(authenticatonHandler) {
|
function validateAuthenticationHandler(authenticationHandler) {
|
||||||
expect(authenticatonHandler).not.toBeUndefined();
|
expect(authenticationHandler).not.toBeUndefined();
|
||||||
expect(typeof authenticatonHandler.getValidatorForProvider).toBe('function');
|
expect(typeof authenticationHandler.getValidatorForProvider).toBe('function');
|
||||||
expect(typeof authenticatonHandler.getValidatorForProvider).toBe('function');
|
expect(typeof authenticationHandler.getValidatorForProvider).toBe('function');
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateAuthenticationAdapter(authAdapter) {
|
function validateAuthenticationAdapter(authAdapter) {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ describe('server', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws if you initialize email adapter incorrecly', done => {
|
it('throws if you initialize email adapter incorrectly', done => {
|
||||||
reconfigureServer({
|
reconfigureServer({
|
||||||
appName: 'unused',
|
appName: 'unused',
|
||||||
verifyUserEmails: true,
|
verifyUserEmails: true,
|
||||||
@@ -428,7 +428,7 @@ describe('server', () => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should suceed if you provide valid ip in masterKeyIps', done => {
|
it('should succeed if you provide valid ip in masterKeyIps', done => {
|
||||||
reconfigureServer({ masterKeyIps: ['1.2.3.4','2001:0db8:0000:0042:0000:8a2e:0370:7334'] })
|
reconfigureServer({ masterKeyIps: ['1.2.3.4','2001:0db8:0000:0042:0000:8a2e:0370:7334'] })
|
||||||
.then(done)
|
.then(done)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class MongoSchemaCollection {
|
|||||||
.then(schemas => schemas.map(mongoSchemaToParseSchema));
|
.then(schemas => schemas.map(mongoSchemaToParseSchema));
|
||||||
}
|
}
|
||||||
|
|
||||||
_fechOneSchemaFrom_SCHEMA(name: string) {
|
_fetchOneSchemaFrom_SCHEMA(name: string) {
|
||||||
return this._collection._rawFind(_mongoSchemaQueryFromNameQuery(name), { limit: 1 }).then(results => {
|
return this._collection._rawFind(_mongoSchemaQueryFromNameQuery(name), { limit: 1 }).then(results => {
|
||||||
if (results.length === 1) {
|
if (results.length === 1) {
|
||||||
return mongoSchemaToParseSchema(results[0]);
|
return mongoSchemaToParseSchema(results[0]);
|
||||||
@@ -150,7 +150,7 @@ class MongoSchemaCollection {
|
|||||||
|
|
||||||
// TODO: don't spend an extra query on finding the schema if the type we are trying to add isn't a GeoPoint.
|
// TODO: don't spend an extra query on finding the schema if the type we are trying to add isn't a GeoPoint.
|
||||||
addFieldIfNotExists(className: string, fieldName: string, type: string) {
|
addFieldIfNotExists(className: string, fieldName: string, type: string) {
|
||||||
return this._fechOneSchemaFrom_SCHEMA(className)
|
return this._fetchOneSchemaFrom_SCHEMA(className)
|
||||||
.then(schema => {
|
.then(schema => {
|
||||||
// The schema exists. Check for existing GeoPoints.
|
// The schema exists. Check for existing GeoPoints.
|
||||||
if (type.type === 'GeoPoint') {
|
if (type.type === 'GeoPoint') {
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ export class MongoStorageAdapter {
|
|||||||
.then(schemaCollection => schemaCollection.findAndDeleteSchema(className))
|
.then(schemaCollection => schemaCollection.findAndDeleteSchema(className))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all data known to this adatper. Used for testing.
|
// Delete all data known to this adapter. Used for testing.
|
||||||
deleteAllClasses() {
|
deleteAllClasses() {
|
||||||
return storageAdapterAllCollections(this)
|
return storageAdapterAllCollections(this)
|
||||||
.then(collections => Promise.all(collections.map(collection => collection.drop())));
|
.then(collections => Promise.all(collections.map(collection => collection.drop())));
|
||||||
@@ -220,7 +220,7 @@ export class MongoStorageAdapter {
|
|||||||
// Pointer field names are passed for legacy reasons: the original mongo
|
// Pointer field names are passed for legacy reasons: the original mongo
|
||||||
// format stored pointer field names differently in the database, and therefore
|
// format stored pointer field names differently in the database, and therefore
|
||||||
// needed to know the type of the field before it could delete it. Future database
|
// needed to know the type of the field before it could delete it. Future database
|
||||||
// adatpers should ignore the pointerFieldNames argument. All the field names are in
|
// adapters should ignore the pointerFieldNames argument. All the field names are in
|
||||||
// fieldNames, they show up additionally in the pointerFieldNames database for use
|
// fieldNames, they show up additionally in the pointerFieldNames database for use
|
||||||
// by the mongo adapter, which deals with the legacy mongo format.
|
// by the mongo adapter, which deals with the legacy mongo format.
|
||||||
|
|
||||||
@@ -265,12 +265,12 @@ export class MongoStorageAdapter {
|
|||||||
// undefined as the reason.
|
// undefined as the reason.
|
||||||
getClass(className) {
|
getClass(className) {
|
||||||
return this._schemaCollection()
|
return this._schemaCollection()
|
||||||
.then(schemasCollection => schemasCollection._fechOneSchemaFrom_SCHEMA(className))
|
.then(schemasCollection => schemasCollection._fetchOneSchemaFrom_SCHEMA(className))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: As yet not particularly well specified. Creates an object. Maybe shouldn't even need the schema,
|
// TODO: As yet not particularly well specified. Creates an object. Maybe shouldn't even need the schema,
|
||||||
// and should infer from the type. Or maybe does need the schema for validations. Or maybe needs
|
// and should infer from the type. Or maybe does need the schema for validations. Or maybe needs
|
||||||
// the schem only for the legacy mongo format. We'll figure that out later.
|
// the schema only for the legacy mongo format. We'll figure that out later.
|
||||||
createObject(className, schema, object) {
|
createObject(className, schema, object) {
|
||||||
schema = convertParseSchemaToMongoSchema(schema);
|
schema = convertParseSchemaToMongoSchema(schema);
|
||||||
const mongoObject = parseObjectToMongoObjectForCreate(className, object, schema);
|
const mongoObject = parseObjectToMongoObjectForCreate(className, object, schema);
|
||||||
|
|||||||
Reference in New Issue
Block a user