forked from tawawa/auth0-rules-testharness-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
72 lines (50 loc) · 1.59 KB
/
test.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
72
'use strict';
var fs = require('fs');
var expect = require('chai').expect;
require('dotenv').config();
var runInSandbox = require("auth0-rules-testharness");
var user = {
"name": "Richard Seldon",
"email": "[email protected]",
"email_verified": true
};
var context = {
"clientID": "wWXS5rz3asdfdfkzbCXho3zNPNv77c",
"clientName": "My Auth0 Client",
"connectionStrategy": "auth0"
};
var configuration = {
NAME: 'world'
};
var params = {
timeout: 5,
ca: '',
tenant: process.env.AUTH0_TENANT,
url: process.env.SANDBOX_URL,
token: process.env.WEBTASK_TOKEN
};
describe('auth0-rules-testharness', function () {
it('should console log "hello, world" - available in output array', function (done) {
console.log("running test...");
var script = fs.readFileSync('./rules/helloWorld.js', 'utf8');
console.log(script);
var callback = function (err, result, output, stats) {
console.log('output: ', output);
console.log('result: ', result);
expect(output[0]).to.equal('hello, world');
done();
};
var args = [user, context, callback];
runInSandbox(script, args, configuration, params);
});
it('should append attribute "foo" to user with value "bar" - available in result object', function (done) {
var script = fs.readFileSync('./rules/helloWorld.js', 'utf8');
var callback = function (err, result, output, stats) {
// console.log('result: ', result);
expect(result.foo).to.equal('bar');
done();
};
var args = [user, context, callback];
runInSandbox(script, args, configuration, params);
});
});