@@ -6,7 +6,7 @@ import axios, { Axios, AxiosHeaders, AxiosError, AxiosPromise, AxiosRequestConfi
66import * as https from 'https' ;
77import { suite , test , slow , timeout } from '@testdeck/mocha' ;
88import { ManagementApiVersions , TunnelManagementHttpClient } from '@microsoft/dev-tunnels-management' ;
9- import { Tunnel , TunnelProgress , TunnelReportProgressEventArgs , ClusterRecommendationResponse , ClusterAvailability } from '@microsoft/dev-tunnels-contracts' ;
9+ import { Tunnel , TunnelPort , TunnelProgress , TunnelReportProgressEventArgs , ClusterRecommendationResponse , ClusterAvailability } from '@microsoft/dev-tunnels-contracts' ;
1010import { CancellationToken , CancellationTokenSource } from 'vscode-jsonrpc' ;
1111
1212@suite
@@ -282,6 +282,7 @@ export class TunnelManagementTests {
282282 callCount ++ ;
283283
284284 const sentTunnel = config . data as Tunnel ;
285+ assert . strictEqual ( config . headers ?. [ 'If-None-Match' ] , '*' ) ;
285286 if ( callCount === 1 ) {
286287 firstTunnelId = sentTunnel ?. tunnelId ;
287288 throw conflictError ;
@@ -315,6 +316,66 @@ export class TunnelManagementTests {
315316 }
316317 }
317318
319+ @test
320+ public async createTunnelSendsIfNoneMatchHeader ( ) {
321+ const requestTunnel = < Tunnel > {
322+ tunnelId : 'tunnelid' ,
323+ clusterId : 'clusterId' ,
324+ } ;
325+ this . nextResponse = < Tunnel > {
326+ tunnelId : 'tunnelid' ,
327+ clusterId : 'clusterId' ,
328+ } ;
329+ const options = {
330+ additionalHeaders : {
331+ 'X-Test' : 'value' ,
332+ } ,
333+ } ;
334+
335+ await this . managementClient . createTunnel ( requestTunnel , options ) ;
336+
337+ assert ( this . lastRequest ) ;
338+ const headers = this . lastRequest ! . config . headers as { [ name : string ] : string } ;
339+ assert . strictEqual ( headers [ 'If-None-Match' ] , '*' ) ;
340+ assert . strictEqual ( headers [ 'If-Not-Match' ] , undefined ) ;
341+ assert . strictEqual ( headers [ 'X-Test' ] , 'value' ) ;
342+ assert . strictEqual (
343+ Object . prototype . hasOwnProperty . call ( options . additionalHeaders , 'If-None-Match' ) ,
344+ false ,
345+ ) ;
346+ }
347+
348+ @test
349+ public async createTunnelPortSendsIfNoneMatchHeader ( ) {
350+ const requestTunnel = < Tunnel > {
351+ tunnelId : 'tunnelid' ,
352+ clusterId : 'clusterId' ,
353+ } ;
354+ const requestPort = < TunnelPort > {
355+ portNumber : 9900 ,
356+ } ;
357+ this . nextResponse = < TunnelPort > {
358+ portNumber : 9900 ,
359+ } ;
360+ const options = {
361+ additionalHeaders : {
362+ 'X-Test' : 'value' ,
363+ } ,
364+ } ;
365+
366+ await this . managementClient . createTunnelPort ( requestTunnel , requestPort , options ) ;
367+
368+ assert ( this . lastRequest ) ;
369+ const headers = this . lastRequest ! . config . headers as { [ name : string ] : string } ;
370+ assert . strictEqual ( headers [ 'If-None-Match' ] , '*' ) ;
371+ assert . strictEqual ( headers [ 'If-Not-Match' ] , undefined ) ;
372+ assert . strictEqual ( headers [ 'X-Test' ] , 'value' ) ;
373+ assert . strictEqual (
374+ Object . prototype . hasOwnProperty . call ( options . additionalHeaders , 'If-None-Match' ) ,
375+ false ,
376+ ) ;
377+ }
378+
318379 @test
319380 public async getClusterRecommendationsReturnsResponse ( ) {
320381 const response = < ClusterRecommendationResponse > {
0 commit comments