1+ /**
2+ * TODO: test for compatibility with other rsa libraries
3+ */
4+
15var assert = require ( 'chai' ) . assert ;
26var _ = require ( 'lodash' ) ;
37var NodeRSA = ( require ( '../src/NodeRSA' ) ) ;
48
9+
510for ( var i = 0 ; i < 100 ; i ++ )
611describe ( 'NodeRSA' , function ( ) {
712 var nodeRSA = null ;
@@ -60,31 +65,31 @@ describe('NodeRSA', function(){
6065 'KY4kQIIx8JEBsAYzgyP2iy0CAwEAAQ==\n' +
6166 '-----END PUBLIC KEY-----' ;
6267
63- false && it ( '.loadFromPrivatePEM() should load private key from PEM string' , function ( ) {
68+ it ( '.loadFromPrivatePEM() should load private key from PEM string' , function ( ) {
6469 privateNodeRSA = new NodeRSA ( privateKeyPEM ) ;
6570 assert . instanceOf ( privateNodeRSA . keyPair , Object ) ;
6671 assert ( privateNodeRSA . isPrivate ( ) ) ;
6772 assert ( privateNodeRSA . isPublic ( ) ) ;
6873 assert ( ! privateNodeRSA . isPublic ( true ) ) ;
6974 } ) ;
7075
71- false && it ( '.loadFromPublicPEM() should load public key from PEM string' , function ( ) {
76+ it ( '.loadFromPublicPEM() should load public key from PEM string' , function ( ) {
7277 publicNodeRSA = new NodeRSA ( publicKeyPEM ) ;
7378 assert . instanceOf ( privateNodeRSA . keyPair , Object ) ;
7479 assert ( publicNodeRSA . isPublic ( ) ) ;
7580 assert ( publicNodeRSA . isPublic ( true ) ) ;
7681 assert ( ! publicNodeRSA . isPrivate ( ) ) ;
7782 } ) ;
7883
79- false && it ( '.toPrivatePEM() should return private PEM string' , function ( ) {
84+ it ( '.toPrivatePEM() should return private PEM string' , function ( ) {
8085 assert . equal ( privateNodeRSA . toPrivatePEM ( ) , privateKeyPEM ) ;
8186 } ) ;
8287
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 ( ) {
8489 assert . equal ( publicNodeRSA . toPublicPEM ( ) , publicKeyPEM ) ;
8590 } ) ;
8691
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 ( ) {
8893 assert . equal ( privateNodeRSA . toPublicPEM ( ) , publicKeyPEM ) ;
8994 } ) ;
9095 } ) ;
@@ -105,12 +110,12 @@ describe('NodeRSA', function(){
105110 var decryptedJSON = null ;
106111
107112 describe ( 'Encrypting' , function ( ) {
108- false && it ( '.encrypt() should return Buffer object' , function ( ) {
113+ it ( '.encrypt() should return Buffer object' , function ( ) {
109114 encryptedBuffer = nodeRSA . encrypt ( dataForEncrypt , null , 'buffer' ) ;
110115 assert ( Buffer . isBuffer ( encryptedBuffer ) ) ;
111116 } ) ;
112117
113- false && it ( '.encrypt() should return base64 encrypted string' , function ( ) {
118+ it ( '.encrypt() should return base64 encrypted string' , function ( ) {
114119 encrypted = nodeRSA . encrypt ( dataForEncrypt ) ;
115120 assert . isString ( encrypted ) ;
116121 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(){
121126 assert ( Buffer . isBuffer ( encryptedLong ) ) ;
122127 } ) ;
123128
124- false && it ( '.encrypt() for js object. Should return Buffer object' , function ( ) {
129+ it ( '.encrypt() for js object. Should return Buffer object' , function ( ) {
125130 encryptedJSON = nodeRSA . encrypt ( JSONForEncrypt , null , 'buffer' ) ;
126131 assert ( Buffer . isBuffer ( encryptedJSON ) ) ;
127132 } ) ;
128133 } ) ;
129134
130135 describe ( 'Decrypting' , function ( ) {
131- false && it ( '.decrypt() should return decrypted Buffer' , function ( ) {
136+ it ( '.decrypt() should return decrypted Buffer' , function ( ) {
132137 decrypted = nodeRSA . decrypt ( encryptedBuffer , 'buffer' ) ;
133138 assert ( Buffer . isBuffer ( decrypted ) ) ;
134139 } ) ;
135140
136- false && it ( '.decrypt() should return decrypted string' , function ( ) {
141+ it ( '.decrypt() should return decrypted string' , function ( ) {
137142 decrypted = nodeRSA . decrypt ( new Buffer ( encrypted , 'base64' ) ) ;
138143 assert . isString ( decrypted ) ;
139144 } ) ;
@@ -143,20 +148,20 @@ describe('NodeRSA', function(){
143148 assert . isString ( decryptedLong ) ;
144149 } ) ;
145150
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 ( ) {
147152 decryptedJSON = nodeRSA . decrypt ( encryptedJSON , 'json' ) ;
148153 assert . isObject ( decryptedJSON ) ;
149154 } ) ;
150155
151- false && it ( 'source and decrypted should be the same' , function ( ) {
156+ it ( 'source and decrypted should be the same' , function ( ) {
152157 assert . equal ( decrypted , dataForEncrypt ) ;
153158 } ) ;
154159
155160 it ( 'long source and decrypted should be the same' , function ( ) {
156161 assert . equal ( decryptedLong , longDataForEncrypt ) ;
157162 } ) ;
158163
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 ( ) {
160165 assert ( _ . isEqual ( decryptedJSON , JSONForEncrypt ) ) ;
161166 } ) ;
162167 } ) ;
0 commit comments