forked from tawawa/auth0-rules-testharness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sample.js
71 lines (56 loc) · 1.69 KB
/
test.sample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict';
var expect = require('chai').expect;
var runInSandbox = require("./index");
var user = {
"email": "[email protected]",
"email_verified": true,
"name": "Richard Seldon",
"given_name": "Richard",
"family_name": "Seldon",
"created_at": "2017-02-22T07:52:40.990Z",
"last_login": "2017-02-23T10:00:27.900Z",
"logins_count": 4
};
var context = {
"clientID": "wWXS5rz3asdfdfkzbCXho3zNPNv77c",
"clientName": "My Auth0 Client",
"connection": "MY-DB",
"connectionStrategy": "auth0",
"protocol": "oidc-basic-profile",
"stats": {"loginsCount": 5}
};
var configuration = {
NAME: 'world'
};
var params = {
timeout: 5,
ca: '',
tenant: 'demo-workshop',
url: 'https://sandbox.it.auth0.com',
token: '<TOKEN>'
};
describe('auth0-rules-testharness', function () {
var ruleScript = `function (user, context, callback) {
console.log('hello,', configuration.NAME);
user.foo = "bar";
callback(null, user, context);
}`;
it('should console log "hello, world" - available in output array', function (done) {
var callback = function (err, result, output, stats) {
// console.log('output: ', output);
expect(output[0]).to.equal('hello, world');
done();
};
var args = [user, context, callback];
runInSandbox(ruleScript, args, configuration, params);
});
it('should append attribute "foo" to user with value "bar" - available in result object', function (done) {
var callback = function (err, result, output, stats) {
// console.log('result: ', result);
expect(result.foo).to.equal('bar');
done();
};
var args = [user, context, callback];
runInSandbox(ruleScript, args, configuration, params);
});
});