adds test that ensure removed linked auth are actually deleted from document
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
var OAuth = require("../src/authDataManager/OAuth1Client");
|
var OAuth = require("../src/authDataManager/OAuth1Client");
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
|
var Config = require("../src/Config");
|
||||||
|
|
||||||
describe('OAuth', function() {
|
describe('OAuth', function() {
|
||||||
|
|
||||||
@@ -266,28 +267,38 @@ describe('OAuth', function() {
|
|||||||
|
|
||||||
model._unlinkFrom("myoauth", {
|
model._unlinkFrom("myoauth", {
|
||||||
success: function(model) {
|
success: function(model) {
|
||||||
|
|
||||||
ok(!model._isLinked("myoauth"),
|
ok(!model._isLinked("myoauth"),
|
||||||
"User should not be linked to myoauth");
|
"User should not be linked to myoauth");
|
||||||
ok(!provider.synchronizedUserId, "User id should be cleared");
|
ok(!provider.synchronizedUserId, "User id should be cleared");
|
||||||
ok(!provider.synchronizedAuthToken, "Auth token should be cleared");
|
ok(!provider.synchronizedAuthToken, "Auth token should be cleared");
|
||||||
ok(!provider.synchronizedExpiration,
|
ok(!provider.synchronizedExpiration,
|
||||||
"Expiration should be cleared");
|
"Expiration should be cleared");
|
||||||
|
// make sure the auth data is properly deleted
|
||||||
|
var config = new Config(Parse.applicationId);
|
||||||
|
config.database.mongoFind('_User', {
|
||||||
|
_id: model.id
|
||||||
|
}).then((res) => {
|
||||||
|
expect(res.length).toBe(1);
|
||||||
|
expect(res[0]._auth_data_myoauth).toBeUndefined();
|
||||||
|
expect(res[0]._auth_data_myoauth).not.toBeNull();
|
||||||
|
|
||||||
model._linkWith("myoauth", {
|
model._linkWith("myoauth", {
|
||||||
success: function(model) {
|
success: function(model) {
|
||||||
ok(provider.synchronizedUserId, "User id should have a value");
|
ok(provider.synchronizedUserId, "User id should have a value");
|
||||||
ok(provider.synchronizedAuthToken,
|
ok(provider.synchronizedAuthToken,
|
||||||
"Auth token should have a value");
|
"Auth token should have a value");
|
||||||
ok(provider.synchronizedExpiration,
|
ok(provider.synchronizedExpiration,
|
||||||
"Expiration should have a value");
|
"Expiration should have a value");
|
||||||
ok(model._isLinked("myoauth"),
|
ok(model._isLinked("myoauth"),
|
||||||
"User should be linked to myoauth");
|
"User should be linked to myoauth");
|
||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
error: function(model, error) {
|
error: function(model, error) {
|
||||||
ok(false, "linking again should succeed");
|
ok(false, "linking again should succeed");
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function(model, error) {
|
error: function(model, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user