File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ var os = require('os');
14
14
var crypto = require ( 'crypto' ) ;
15
15
var getmac = require ( 'getmac' ) ;
16
16
17
- //options
18
- exports . options = {
17
+ var defaults = {
19
18
encryption : 'md5' , //encryption algorithm
20
19
encoding : 'hex' , //encoding format
21
20
keyLength : 20 , //default key length
@@ -25,6 +24,14 @@ exports.options = {
25
24
secret : undefined //encyption key default to machine id
26
25
} ;
27
26
27
+ //options
28
+ exports . options = defaults ;
29
+
30
+ //restore default settings
31
+ exports . restore = function ( ) {
32
+ exports . options = defaults ;
33
+ } ;
34
+
28
35
29
36
/**
30
37
* @function
Original file line number Diff line number Diff line change @@ -8,10 +8,15 @@ var keygen = require(path.join(__dirname, '..'));
8
8
9
9
describe ( 'keygen' , function ( ) {
10
10
var key ;
11
+
11
12
var data = {
12
13
uuid : '123dr34'
13
14
} ;
14
15
16
+ beforeEach ( function ( ) {
17
+ keygen . restore ( ) ;
18
+ } ) ;
19
+
15
20
it ( 'should be able to obtain host os details' , function ( done ) {
16
21
keygen . os ( function ( error , os ) {
17
22
@@ -108,4 +113,18 @@ describe('keygen', function() {
108
113
} ) ;
109
114
} ) ;
110
115
116
+ it ( 'should be able to use different encryption algorithm' , function ( done ) {
117
+
118
+ keygen . options . encryption = 'sha256' ;
119
+
120
+ keygen . generate ( data , function ( error , _key ) {
121
+ //assert
122
+ expect ( error ) . to . not . exist ;
123
+ expect ( _key ) . to . exist ;
124
+ done ( error , _key ) ;
125
+ } ) ;
126
+
127
+ } ) ;
128
+
129
+
111
130
} ) ;
You can’t perform that action at this time.
0 commit comments