1
+ /**
2
+ * TODO: test for compatibility with other rsa libraries
3
+ */
4
+
1
5
var assert = require ( 'chai' ) . assert ;
2
6
var _ = require ( 'lodash' ) ;
3
7
var NodeRSA = ( require ( '../src/NodeRSA' ) ) ;
4
8
9
+
5
10
for ( var i = 0 ; i < 100 ; i ++ )
6
11
describe ( 'NodeRSA' , function ( ) {
7
12
var nodeRSA = null ;
@@ -60,31 +65,31 @@ describe('NodeRSA', function(){
60
65
'KY4kQIIx8JEBsAYzgyP2iy0CAwEAAQ==\n' +
61
66
'-----END PUBLIC KEY-----' ;
62
67
63
- false && it ( '.loadFromPrivatePEM() should load private key from PEM string' , function ( ) {
68
+ it ( '.loadFromPrivatePEM() should load private key from PEM string' , function ( ) {
64
69
privateNodeRSA = new NodeRSA ( privateKeyPEM ) ;
65
70
assert . instanceOf ( privateNodeRSA . keyPair , Object ) ;
66
71
assert ( privateNodeRSA . isPrivate ( ) ) ;
67
72
assert ( privateNodeRSA . isPublic ( ) ) ;
68
73
assert ( ! privateNodeRSA . isPublic ( true ) ) ;
69
74
} ) ;
70
75
71
- false && it ( '.loadFromPublicPEM() should load public key from PEM string' , function ( ) {
76
+ it ( '.loadFromPublicPEM() should load public key from PEM string' , function ( ) {
72
77
publicNodeRSA = new NodeRSA ( publicKeyPEM ) ;
73
78
assert . instanceOf ( privateNodeRSA . keyPair , Object ) ;
74
79
assert ( publicNodeRSA . isPublic ( ) ) ;
75
80
assert ( publicNodeRSA . isPublic ( true ) ) ;
76
81
assert ( ! publicNodeRSA . isPrivate ( ) ) ;
77
82
} ) ;
78
83
79
- false && it ( '.toPrivatePEM() should return private PEM string' , function ( ) {
84
+ it ( '.toPrivatePEM() should return private PEM string' , function ( ) {
80
85
assert . equal ( privateNodeRSA . toPrivatePEM ( ) , privateKeyPEM ) ;
81
86
} ) ;
82
87
83
- false && it ( '.toPublicPEM() from public key should return public PEM string' , function ( ) {
88
+ it ( '.toPublicPEM() from public key should return public PEM string' , function ( ) {
84
89
assert . equal ( publicNodeRSA . toPublicPEM ( ) , publicKeyPEM ) ;
85
90
} ) ;
86
91
87
- false && it ( '.toPublicPEM() from private key should return public PEM string' , function ( ) {
92
+ it ( '.toPublicPEM() from private key should return public PEM string' , function ( ) {
88
93
assert . equal ( privateNodeRSA . toPublicPEM ( ) , publicKeyPEM ) ;
89
94
} ) ;
90
95
} ) ;
@@ -105,12 +110,12 @@ describe('NodeRSA', function(){
105
110
var decryptedJSON = null ;
106
111
107
112
describe ( 'Encrypting' , function ( ) {
108
- false && it ( '.encrypt() should return Buffer object' , function ( ) {
113
+ it ( '.encrypt() should return Buffer object' , function ( ) {
109
114
encryptedBuffer = nodeRSA . encrypt ( dataForEncrypt , null , 'buffer' ) ;
110
115
assert ( Buffer . isBuffer ( encryptedBuffer ) ) ;
111
116
} ) ;
112
117
113
- false && it ( '.encrypt() should return base64 encrypted string' , function ( ) {
118
+ it ( '.encrypt() should return base64 encrypted string' , function ( ) {
114
119
encrypted = nodeRSA . encrypt ( dataForEncrypt ) ;
115
120
assert . isString ( encrypted ) ;
116
121
assert . match ( encrypted , / ^ ( [ A - Z a - z 0 - 9 + / ] { 4 } ) * ( [ A - Z a - z 0 - 9 + / ] { 4 } | [ A - Z a - z 0 - 9 + / ] { 3 } = | [ A - Z a - z 0 - 9 + / ] { 2 } = = ) $ / ) ;
@@ -121,19 +126,19 @@ describe('NodeRSA', function(){
121
126
assert ( Buffer . isBuffer ( encryptedLong ) ) ;
122
127
} ) ;
123
128
124
- false && it ( '.encrypt() for js object. Should return Buffer object' , function ( ) {
129
+ it ( '.encrypt() for js object. Should return Buffer object' , function ( ) {
125
130
encryptedJSON = nodeRSA . encrypt ( JSONForEncrypt , null , 'buffer' ) ;
126
131
assert ( Buffer . isBuffer ( encryptedJSON ) ) ;
127
132
} ) ;
128
133
} ) ;
129
134
130
135
describe ( 'Decrypting' , function ( ) {
131
- false && it ( '.decrypt() should return decrypted Buffer' , function ( ) {
136
+ it ( '.decrypt() should return decrypted Buffer' , function ( ) {
132
137
decrypted = nodeRSA . decrypt ( encryptedBuffer , 'buffer' ) ;
133
138
assert ( Buffer . isBuffer ( decrypted ) ) ;
134
139
} ) ;
135
140
136
- false && it ( '.decrypt() should return decrypted string' , function ( ) {
141
+ it ( '.decrypt() should return decrypted string' , function ( ) {
137
142
decrypted = nodeRSA . decrypt ( new Buffer ( encrypted , 'base64' ) ) ;
138
143
assert . isString ( decrypted ) ;
139
144
} ) ;
@@ -143,20 +148,20 @@ describe('NodeRSA', function(){
143
148
assert . isString ( decryptedLong ) ;
144
149
} ) ;
145
150
146
- false && it ( '.decrypt() for js object. Should return decrypted js object' , function ( ) {
151
+ it ( '.decrypt() for js object. Should return decrypted js object' , function ( ) {
147
152
decryptedJSON = nodeRSA . decrypt ( encryptedJSON , 'json' ) ;
148
153
assert . isObject ( decryptedJSON ) ;
149
154
} ) ;
150
155
151
- false && it ( 'source and decrypted should be the same' , function ( ) {
156
+ it ( 'source and decrypted should be the same' , function ( ) {
152
157
assert . equal ( decrypted , dataForEncrypt ) ;
153
158
} ) ;
154
159
155
160
it ( 'long source and decrypted should be the same' , function ( ) {
156
161
assert . equal ( decryptedLong , longDataForEncrypt ) ;
157
162
} ) ;
158
163
159
- false && it ( 'source JSON and decrypted JSON should be the same' , function ( ) {
164
+ it ( 'source JSON and decrypted JSON should be the same' , function ( ) {
160
165
assert ( _ . isEqual ( decryptedJSON , JSONForEncrypt ) ) ;
161
166
} ) ;
162
167
} ) ;
0 commit comments