1- var assert = require ( 'chai' ) . assert
2- var NodeRSA = ( require ( '../src/NodeRSA' ) )
1+ var assert = require ( 'chai' ) . assert ;
2+ var _ = require ( 'lodash' ) ;
3+ var NodeRSA = ( require ( '../src/NodeRSA' ) ) ;
34
5+ for ( var i = 0 ; i < 100 ; i ++ )
46describe ( 'NodeRSA' , function ( ) {
57 var nodeRSA = null ;
68 var privateNodeRSA = null ;
@@ -58,31 +60,31 @@ describe('NodeRSA', function(){
5860 'KY4kQIIx8JEBsAYzgyP2iy0CAwEAAQ==\n' +
5961 '-----END PUBLIC KEY-----' ;
6062
61- it ( '.loadFromPrivatePEM() should load private key from PEM string' , function ( ) {
63+ false && it ( '.loadFromPrivatePEM() should load private key from PEM string' , function ( ) {
6264 privateNodeRSA = new NodeRSA ( privateKeyPEM ) ;
6365 assert . instanceOf ( privateNodeRSA . keyPair , Object ) ;
6466 assert ( privateNodeRSA . isPrivate ( ) ) ;
6567 assert ( privateNodeRSA . isPublic ( ) ) ;
6668 assert ( ! privateNodeRSA . isPublic ( true ) ) ;
6769 } ) ;
6870
69- it ( '.loadFromPublicPEM() should load public key from PEM string' , function ( ) {
71+ false && it ( '.loadFromPublicPEM() should load public key from PEM string' , function ( ) {
7072 publicNodeRSA = new NodeRSA ( publicKeyPEM ) ;
7173 assert . instanceOf ( privateNodeRSA . keyPair , Object ) ;
7274 assert ( publicNodeRSA . isPublic ( ) ) ;
7375 assert ( publicNodeRSA . isPublic ( true ) ) ;
7476 assert ( ! publicNodeRSA . isPrivate ( ) ) ;
7577 } ) ;
7678
77- it ( '.toPrivatePEM() should return private PEM string' , function ( ) {
79+ false && it ( '.toPrivatePEM() should return private PEM string' , function ( ) {
7880 assert . equal ( privateNodeRSA . toPrivatePEM ( ) , privateKeyPEM ) ;
7981 } ) ;
8082
81- it ( '.toPublicPEM() from public key should return public PEM string' , function ( ) {
83+ false && it ( '.toPublicPEM() from public key should return public PEM string' , function ( ) {
8284 assert . equal ( publicNodeRSA . toPublicPEM ( ) , publicKeyPEM ) ;
8385 } ) ;
8486
85- it ( '.toPublicPEM() from private key should return public PEM string' , function ( ) {
87+ false && it ( '.toPublicPEM() from private key should return public PEM string' , function ( ) {
8688 assert . equal ( privateNodeRSA . toPublicPEM ( ) , publicKeyPEM ) ;
8789 } ) ;
8890 } ) ;
@@ -103,36 +105,36 @@ describe('NodeRSA', function(){
103105 var decryptedJSON = null ;
104106
105107 describe ( 'Encrypting' , function ( ) {
106- it ( '.encrypt() should return Buffer object' , function ( ) {
108+ false && it ( '.encrypt() should return Buffer object' , function ( ) {
107109 encryptedBuffer = nodeRSA . encrypt ( dataForEncrypt , null , 'buffer' ) ;
108110 assert ( Buffer . isBuffer ( encryptedBuffer ) ) ;
109111 } ) ;
110112
111- it ( '.encrypt() should return base64 encrypted string' , function ( ) {
113+ false && it ( '.encrypt() should return base64 encrypted string' , function ( ) {
112114 encrypted = nodeRSA . encrypt ( dataForEncrypt ) ;
113115 assert . isString ( encrypted ) ;
114116 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 } = = ) $ / ) ;
115117 } ) ;
116118
117- it ( '.encrypt() should return encrypted string for long message' , function ( ) {
118- encryptedLong = nodeRSA . encrypt ( longDataForEncrypt , null , Buffer ) ;
119+ it ( '.encrypt() should return encrypted Buffer for long message' , function ( ) {
120+ encryptedLong = nodeRSA . encrypt ( longDataForEncrypt , null , 'buffer' ) ;
119121 assert ( Buffer . isBuffer ( encryptedLong ) ) ;
120122 } ) ;
121123
122- it ( '.encrypt() for js object) . Should return Buffer object' , function ( ) {
124+ false && it ( '.encrypt() for js object. Should return Buffer object' , function ( ) {
123125 encryptedJSON = nodeRSA . encrypt ( JSONForEncrypt , null , 'buffer' ) ;
124126 assert ( Buffer . isBuffer ( encryptedJSON ) ) ;
125127 } ) ;
126128 } ) ;
127129
128130 describe ( 'Decrypting' , function ( ) {
129- it ( '.decrypt() should return decrypted Buffer' , function ( ) {
131+ false && it ( '.decrypt() should return decrypted Buffer' , function ( ) {
130132 decrypted = nodeRSA . decrypt ( encryptedBuffer , 'buffer' ) ;
131133 assert ( Buffer . isBuffer ( decrypted ) ) ;
132134 } ) ;
133135
134- it ( '.decrypt() should return decrypted string' , function ( ) {
135- decrypted = nodeRSA . decrypt ( new Buffer ( encrypted , 'base64' ) , 'utf8' ) ;
136+ false && it ( '.decrypt() should return decrypted string' , function ( ) {
137+ decrypted = nodeRSA . decrypt ( new Buffer ( encrypted , 'base64' ) ) ;
136138 assert . isString ( decrypted ) ;
137139 } ) ;
138140
@@ -141,20 +143,20 @@ describe('NodeRSA', function(){
141143 assert . isString ( decryptedLong ) ;
142144 } ) ;
143145
144- it ( '.decrypt() for js object. Should return decrypted js object' , function ( ) {
145- decryptedJSON = nodeRSA . decrypt ( new Buffer ( encrypted , 'base64' ) , 'utf8 ') ;
146+ false && it ( '.decrypt() for js object. Should return decrypted js object' , function ( ) {
147+ decryptedJSON = nodeRSA . decrypt ( encryptedJSON , 'json ' ) ;
146148 assert . isObject ( decryptedJSON ) ;
147149 } ) ;
148150
149- it ( 'source and decrypted should be the same' , function ( ) {
151+ false && it ( 'source and decrypted should be the same' , function ( ) {
150152 assert . equal ( decrypted , dataForEncrypt ) ;
151153 } ) ;
152154
153155 it ( 'long source and decrypted should be the same' , function ( ) {
154156 assert . equal ( decryptedLong , longDataForEncrypt ) ;
155157 } ) ;
156158
157- it ( 'source JSON and decrypted JSON should be the same' , function ( ) {
159+ false && it ( 'source JSON and decrypted JSON should be the same' , function ( ) {
158160 assert ( _ . isEqual ( decryptedJSON , JSONForEncrypt ) ) ;
159161 } ) ;
160162 } ) ;
0 commit comments