@@ -92,7 +92,7 @@ describe("JWE Crypto", () => {
9292 delete config [ "publicKeyFingerprintType" ] ;
9393 assert . throws (
9494 ( ) => new Crypto ( config ) ,
95- / C o n f i g n o t v a l i d : p r o p e r t i e s F i n g e r p r i n t s h o u l d b e : ' c e r t i f i c a t e ' o r ' p u b l i c K e y ' /
95+ / C o n f i g n o t v a l i d : p u b l i c K e y F i n g e r p r i n t T y p e s h o u l d b e : ' c e r t i f i c a t e ' o r ' p u b l i c K e y ' /
9696 ) ;
9797 } ) ;
9898
@@ -108,16 +108,34 @@ describe("JWE Crypto", () => {
108108 config . publicKeyFingerprintType = "foobar" ;
109109 assert . throws (
110110 ( ) => new Crypto ( config ) ,
111- / C o n f i g n o t v a l i d : p r o p e r t i e s F i n g e r p r i n t s h o u l d b e : ' c e r t i f i c a t e ' o r ' p u b l i c K e y ' /
111+ / C o n f i g n o t v a l i d : p u b l i c K e y F i n g e r p r i n t T y p e s h o u l d b e : ' c e r t i f i c a t e ' o r ' p u b l i c K e y ' /
112112 ) ;
113113 } ) ;
114114
115- it ( "with right publicKeyFingerprintType: certificate" , ( ) => {
115+ it ( "with right publicKeyFingerprintType: certificate and dataEncoding: base64 " , ( ) => {
116116 const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
117117 config . publicKeyFingerprintType = "certificate" ;
118+ config . dataEncoding = "base64" ;
118119 assert . doesNotThrow ( ( ) => new Crypto ( config ) ) ;
119120 } ) ;
120121
122+ it ( "with right publicKeyFingerprintType: certificate and dataEncoding: hex" , ( ) => {
123+ const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
124+ config . publicKeyFingerprintType = "certificate" ;
125+ config . dataEncoding = "hex" ;
126+ assert . doesNotThrow ( ( ) => new Crypto ( config ) ) ;
127+ } ) ;
128+
129+ it ( "with right publicKeyFingerprintType: certificate and dataEncoding: null" , ( ) => {
130+ const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
131+ config . publicKeyFingerprintType = "certificate" ;
132+ delete config [ "dataEncoding" ] ;
133+ assert . throws (
134+ ( ) => new Crypto ( config ) ,
135+ / C o n f i g n o t v a l i d : i f p u b l i c K e y F i n g e r p r i n t T y p e i s ' c e r t i f i c a t e ' d a t a E n c o d i n g m u s t b e e i t h e r ' b a s e 6 4 ' o r ' h e x ' /
136+ ) ;
137+ } ) ;
138+
121139 it ( "with right publicKeyFingerprintType: publicKey" , ( ) => {
122140 const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
123141 config . publicKeyFingerprintType = "publicKey" ;
0 commit comments