@@ -59,19 +59,20 @@ const mapObject = {
5959} ;
6060describe ( 'openlayers_VectorTileSuperMapRest' , ( ) => {
6161 var testDiv , map , vectorTileOptions , vectorTileSource , originalTimeout , vectorLayer , spyGet , spyPost , spyCommit ;
62+ const encrptSpec = {
63+ keyLength : 256 ,
64+ attributes : 'abcd' ,
65+ version : '1.1' ,
66+ algorithm : 'AES'
67+ } ;
6268 const mockCallback = ( testUrl ) => {
6369 if ( ( url . match ( / .+ (? = ( \/ r e s t j s r \/ v 1 \/ v e c t o r t i l e \/ | \/ r e s t \/ m a p s \/ ) ) / ) || [ ] ) [ 0 ] === testUrl ) {
6470 return Promise . resolve (
6571 new Response (
6672 JSON . stringify ( [
6773 {
6874 serviceEncryptInfo : {
69- encrptSpec : {
70- keyLength : 256 ,
71- attributes : 'abcd' ,
72- version : '1.1' ,
73- algorithm : 'AES'
74- } ,
75+ encrptSpec,
7576 updateTime : 'Fri Mar 15 08:52:15 CST 2024' ,
7677 encrptKeyID : 'keyIDNAME'
7778 } ,
@@ -175,7 +176,8 @@ describe('openlayers_VectorTileSuperMapRest', () => {
175176
176177 it ( 'mvt_decrypt ' , ( done ) => {
177178 const spy = jasmine . createSpy ( 'test' ) ;
178- const spyEncrypt = spyOn ( EncryptRequest . prototype , 'request' ) . and . callFake ( ( ) => ( { json : ( ) => Promise . resolve ( 'l3nQtAUM4li87qMfO68exInHVFQ5gS3a6pb8ySIbib8=' ) } ) ) ;
179+ const serviceKey = 'l3nQtAUM4li87qMfO68exInHVFQ5gS3a6pb8ySIbib8=' ;
180+ const spyEncrypt = spyOn ( EncryptRequest . prototype , 'request' ) . and . callFake ( ( ) => ( { json : ( ) => Promise . resolve ( serviceKey ) } ) ) ;
179181 new MapService ( url ) . getMapInfo ( ( serviceResult ) => {
180182 map = new Map ( {
181183 target : 'map' ,
@@ -185,10 +187,11 @@ describe('openlayers_VectorTileSuperMapRest', () => {
185187 } )
186188 } ) ;
187189 vectorTileOptions = VectorTileSuperMapRest . optionsFromMapJSON ( url , serviceResult . result ) ;
188- vectorTileOptions . decrypt = true ;
189190 vectorTileOptions . format = new MVT ( {
190191 featureClass : Feature
191192 } ) ;
193+ vectorTileOptions . decrypt = function ( ) { return [ ] } ;
194+ vectorTileOptions . decryptCompletedFunction = function ( ) { } ;
192195 vectorTileOptions . tileLoadFunction = ( tile ) => {
193196 tile . setLoader ( ( ) => {
194197 spy ( ) ;
@@ -204,7 +207,18 @@ describe('openlayers_VectorTileSuperMapRest', () => {
204207 expect ( vectorTileOptions ) . not . toBeNull ( ) ;
205208 expect ( spy . calls . count ( ) ) . toBe ( 1 ) ;
206209 expect ( spyEncrypt ) . toHaveBeenCalled ( ) ;
207- expect ( vectorTileSource . serviceKey ) . not . toBeUndefined ( ) ;
210+ expect ( vectorTileSource . decryptOptions ) . not . toBeUndefined ( ) ;
211+ expect ( vectorTileSource . decryptOptions . key ) . toBe ( serviceKey ) ;
212+ expect ( vectorTileSource . decryptOptions . algorithm ) . toEqual ( encrptSpec . algorithm ) ;
213+ expect ( vectorTileSource . decryptOptions . decrypt ) . not . toBeUndefined ( ) ;
214+ expect ( vectorTileSource . decryptOptions . decryptCompletedFunction ) . not . toBeUndefined ( ) ;
215+ let testData = new Uint8Array ( ) ;
216+ let resultData = vectorTileSource . _decryptMvt ( testData ) ;
217+ expect ( resultData . slice ( 0 ) . join ( ',' ) ) . toEqual ( testData . slice ( 0 ) . join ( ',' ) ) ;
218+ vectorTileSource . decryptOptions = null ;
219+ testData = new Uint8Array ( [ 5 , 10 ] ) ;
220+ resultData = vectorTileSource . _decryptMvt ( testData ) ;
221+ expect ( resultData . slice ( 0 ) . join ( ',' ) ) . toEqual ( testData . slice ( 0 ) . join ( ',' ) ) ;
208222 spy . calls . reset ( ) ;
209223 spyEncrypt . calls . reset ( ) ;
210224 done ( ) ;
0 commit comments