1
- let axios = require ( "axios" ) ;
2
- let FormData = require ( "form-data" ) ;
3
- let chai = require ( "chai" ) ;
4
- const EcCrypto = require ( "cassproject/src/com/eduworks/ec/crypto/EcCrypto" ) ;
5
- const EcAes = require ( "cassproject/src/com/eduworks/ec/crypto/EcAes" ) ;
6
- const EcRemoteLinkedData = require ( "cassproject/src/org/cassproject/schema/general/EcRemoteLinkedData" ) ;
7
- const EcRemoteIdentityManager = require ( "cassproject/src/org/cassproject/ebac/identity/remote/EcRemoteIdentityManager" ) ;
8
- const EcIdentityManager = require ( "cassproject/src/org/cassproject/ebac/identity/EcIdentityManager" ) ;
9
- const EcIdentity = require ( "cassproject/src/org/cassproject/ebac/identity/EcIdentity" ) ;
10
- const EcPpk = require ( "cassproject/src/com/eduworks/ec/crypto/EcPpk" ) ;
1
+ global . axios = require ( 'axios' ) ;
2
+ let chai = require ( 'chai' ) ;
3
+ const EcAes = require ( 'cassproject/src/com/eduworks/ec/crypto/EcAes' ) ;
4
+ const EcRemoteIdentityManager = require ( 'cassproject/src/org/cassproject/ebac/identity/remote/EcRemoteIdentityManager' ) ;
5
+ const EcIdentityManager = require ( 'cassproject/src/org/cassproject/ebac/identity/EcIdentityManager' ) ;
6
+ const EcIdentity = require ( 'cassproject/src/org/cassproject/ebac/identity/EcIdentity' ) ;
7
+ const EcPpk = require ( 'cassproject/src/com/eduworks/ec/crypto/EcPpk' ) ;
11
8
12
- let hrtime = function ( ) {
13
- try {
14
- return [ Math . round ( performance . now ( ) / 1000 ) , performance . now ( ) * 1000 ] ;
15
- } catch ( e ) {
16
- // Eat quietly.
17
- }
18
- return process . hrtime ( ) ;
19
- } ;
9
+ let assert = chai . assert ;
20
10
21
- var should = chai . should ( ) ;
22
- var expect = chai . expect ;
23
- var assert = chai . assert ;
24
-
25
-
26
- describe ( "SkyID Adapter" , function ( ) {
11
+ describe ( 'SkyID Adapter' , function ( ) {
27
12
this . timeout ( 30000 ) ;
28
13
let username = EcAes . newIv ( 6 ) ;
29
14
let password = EcAes . newSecret ( 6 ) ;
30
15
let newPassword = EcAes . newSecret ( 6 ) ;
31
- let name = "Test User" ;
32
- let email = username + "@test.cassproject.org" ;
16
+ let name = 'Test User' ;
33
17
let ident = null ;
34
18
35
19
it ( 'create user' , async ( ) => {
36
20
let rld = new EcRemoteIdentityManager ( ) ;
37
- rld . server = " http://localhost/api/" ;
38
- await rld . configureFromServer ( null , null ) ;
39
- rld . startLogin ( username , password ) ;
21
+ rld . server = ' http://localhost/api/' ;
22
+ await rld . configureFromServer ( null , null ) ;
23
+ rld . startLogin ( username , password ) ;
40
24
let im = new EcIdentityManager ( ) ;
41
- await rld . create ( null , null , im ) ;
25
+ await rld . create ( null , null , im ) ;
42
26
im = await rld . fetch ( ) ;
43
27
ident = new EcIdentity ( ) ;
44
- ident . ppk = await EcPpk . generateKeyAsync ( null , null ) ;
28
+ ident . ppk = await EcPpk . generateKeyAsync ( null , null ) ;
45
29
ident . displayName = name ;
46
30
im . addIdentity ( ident ) ;
47
- await rld . commit ( null , null , im ) ;
31
+ await rld . commit ( null , null , im ) ;
48
32
} ) . timeout ( 2000 ) ;
49
33
50
34
it ( 'change password' , async ( ) => {
51
35
let rld = new EcRemoteIdentityManager ( ) ;
52
- rld . server = " http://localhost/api/" ;
53
- await rld . configureFromServer ( null , null ) ;
54
- rld . startLogin ( username , password ) ;
36
+ rld . server = ' http://localhost/api/' ;
37
+ await rld . configureFromServer ( null , null ) ;
38
+ rld . startLogin ( username , password ) ;
55
39
let im = await rld . fetch ( ) ;
56
- assert . equal ( im . ids [ 0 ] . ppk . toPem ( ) , ident . ppk . toPem ( ) ) ;
57
- rld . changePassword ( username , password , newPassword ) ;
58
- await rld . commit ( null , null , im ) ;
40
+ assert . equal ( im . ids [ 0 ] . ppk . toPem ( ) , ident . ppk . toPem ( ) ) ;
41
+ rld . changePassword ( username , password , newPassword ) ;
42
+ await rld . commit ( null , null , im ) ;
59
43
} ) . timeout ( 2000 ) ;
60
-
44
+
61
45
it ( 'load user' , async ( ) => {
62
46
let rld = new EcRemoteIdentityManager ( ) ;
63
- rld . server = " http://localhost/api/" ;
64
- await rld . configureFromServer ( null , null ) ;
65
- rld . startLogin ( username , newPassword ) ;
47
+ rld . server = ' http://localhost/api/' ;
48
+ await rld . configureFromServer ( null , null ) ;
49
+ rld . startLogin ( username , newPassword ) ;
66
50
let im = await rld . fetch ( ) ;
67
- assert . equal ( im . ids [ 0 ] . ppk . toPem ( ) , ident . ppk . toPem ( ) ) ;
51
+ assert . equal ( im . ids [ 0 ] . ppk . toPem ( ) , ident . ppk . toPem ( ) ) ;
68
52
} ) . timeout ( 2000 ) ;
69
-
70
- } ) ;
53
+ } ) ;
0 commit comments