@@ -90,6 +90,27 @@ public void VirtualClientProxyApiClientUsesTheExpectedChunkSizeWhenDefinedInTheA
9090 Assert . AreEqual ( expectedChunkSize , this . apiClient . ChunkSize ) ;
9191 }
9292
93+ [ Test ]
94+ [ TestCase ( "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , null ,
95+ "/api/blobs/anyfile.log?storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8" ) ]
96+ //
97+ [ TestCase ( "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , "/any/path/to/blob" ,
98+ "/api/blobs/anyfile.log?storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8&blobPath=/any/path/to/blob" ) ]
99+ //
100+ [ TestCase ( "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , "any/path/to/blob/" ,
101+ "/api/blobs/anyfile.log?storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8&blobPath=any/path/to/blob" ) ]
102+ //
103+ [ TestCase ( "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , "/any/path/to/blob/" ,
104+ "/api/blobs/anyfile.log?storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8&blobPath=/any/path/to/blob" ) ]
105+ public void VirtualClientProxyApiClientFormsTheCorrectUriRouteForAGivenDescriptor ( string storeType , string blobName , string containerName , string contentType , string contentEncoding , string blobPath , string expectedRoute )
106+ {
107+ string encoding = Encoding . UTF8 . WebName ;
108+ ProxyBlobDescriptor descriptor = new ProxyBlobDescriptor ( storeType , blobName , containerName , contentType , contentEncoding , blobPath ) ;
109+
110+ string actualRoute = VirtualClientProxyApiClient . CreateBlobApiRoute ( descriptor ) ;
111+ Assert . AreEqual ( expectedRoute , actualRoute ) ;
112+ }
113+
93114 [ Test ]
94115 [ TestCase ( "VirtualClient" , "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , null ,
95116 "/api/blobs/anyfile.log?source=VirtualClient&storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8" ) ]
@@ -105,23 +126,40 @@ public void VirtualClientProxyApiClientUsesTheExpectedChunkSizeWhenDefinedInTheA
105126 public void VirtualClientProxyApiClientFormsTheCorrectUriRouteForAGivenDescriptor ( string source , string storeType , string blobName , string containerName , string contentType , string contentEncoding , string blobPath , string expectedRoute )
106127 {
107128 string encoding = Encoding . UTF8 . WebName ;
108- ProxyBlobDescriptor descriptor = new ProxyBlobDescriptor ( source , storeType , blobName , containerName , contentType , contentEncoding , blobPath ) ;
129+ ProxyBlobDescriptor descriptor = new ProxyBlobDescriptor ( storeType , blobName , containerName , contentType , contentEncoding , blobPath , source ) ;
109130
110131 string actualRoute = VirtualClientProxyApiClient . CreateBlobApiRoute ( descriptor ) ;
111132 Assert . AreEqual ( expectedRoute , actualRoute ) ;
112133 }
113134
135+ [ Test ]
136+ [ TestCase ( "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , null ,
137+ "/api/blobs/anyfile.log?api-key=123&chunk-size=10000&storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8" ) ]
138+ //
139+ [ TestCase ( "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , "/any/path/to/blob" ,
140+ "/api/blobs/anyfile.log?api-key=123&chunk-size=10000&storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8&blobPath=/any/path/to/blob" ) ]
141+ public void VirtualClientProxyApiClientFormsTheCorrectUriRouteForAGivenDescriptor_WhenQueryStringParametersAreProvidedOnTheBaseUri_1 (
142+ string storeType , string blobName , string containerName , string contentType , string contentEncoding , string blobPath , string expectedRoute )
143+ {
144+ string encoding = Encoding . UTF8 . WebName ;
145+ ProxyBlobDescriptor descriptor = new ProxyBlobDescriptor ( storeType , blobName , containerName , contentType , contentEncoding , blobPath ) ;
146+
147+ Uri baseUri = new Uri ( "https://any.proxy.api.endpoint:5000?api-key=123&chunk-size=10000" ) ;
148+ string actualRoute = VirtualClientProxyApiClient . CreateBlobApiRoute ( descriptor , baseUri . Query ) ;
149+ Assert . AreEqual ( expectedRoute , actualRoute ) ;
150+ }
151+
114152 [ Test ]
115153 [ TestCase ( "VirtualClient" , "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , null ,
116154 "/api/blobs/anyfile.log?api-key=123&chunk-size=10000&source=VirtualClient&storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8" ) ]
117155 //
118156 [ TestCase ( "VirtualClient" , "Content" , "anyfile.log" , "anycontainer" , "application/octet-stream" , "utf-8" , "/any/path/to/blob" ,
119157 "/api/blobs/anyfile.log?api-key=123&chunk-size=10000&source=VirtualClient&storeType=Content&containerName=anycontainer&contentType=application/octet-stream&contentEncoding=utf-8&blobPath=/any/path/to/blob" ) ]
120- public void VirtualClientProxyApiClientFormsTheCorrectUriRouteForAGivenDescriptor_WhenQueryStringParametersAreProvidedOnTheBaseUri (
158+ public void VirtualClientProxyApiClientFormsTheCorrectUriRouteForAGivenDescriptor_WhenQueryStringParametersAreProvidedOnTheBaseUri_2 (
121159 string source , string storeType , string blobName , string containerName , string contentType , string contentEncoding , string blobPath , string expectedRoute )
122160 {
123161 string encoding = Encoding . UTF8 . WebName ;
124- ProxyBlobDescriptor descriptor = new ProxyBlobDescriptor ( source , storeType , blobName , containerName , contentType , contentEncoding , blobPath ) ;
162+ ProxyBlobDescriptor descriptor = new ProxyBlobDescriptor ( storeType , blobName , containerName , contentType , contentEncoding , blobPath , source ) ;
125163
126164 Uri baseUri = new Uri ( "https://any.proxy.api.endpoint:5000?api-key=123&chunk-size=10000" ) ;
127165 string actualRoute = VirtualClientProxyApiClient . CreateBlobApiRoute ( descriptor , baseUri . Query ) ;
@@ -748,16 +786,16 @@ private static ProxyTelemetryMessage CreateMockProxyTelemetryMessage()
748786 } ;
749787 }
750788
751- private static ProxyBlobDescriptor GetBlobDescriptor ( bool withPath = false )
789+ private static ProxyBlobDescriptor GetBlobDescriptor ( bool withPath = false , string withSource = null )
752790 {
753791 return new ProxyBlobDescriptor (
754- "VirtualClient" ,
755792 "Packages" ,
756793 "blobname.1.0.0.zip" ,
757794 "packages" ,
758795 "application/octet-stream" ,
759796 Encoding . UTF8 . WebName ,
760- withPath ? "/path/to/blob" : null ) ;
797+ withPath ? "/path/to/blob" : null ,
798+ ! string . IsNullOrWhiteSpace ( withSource ) ? withSource : null ) ;
761799 }
762800
763801 private static string GetExpectedBlobPathAndQuery ( ProxyBlobDescriptor descriptor , string queryString = null )
@@ -771,13 +809,17 @@ private static string GetExpectedBlobPathAndQuery(ProxyBlobDescriptor descriptor
771809 string expectedBlobPath = descriptor . BlobPath ;
772810
773811 string fullQueryString =
774- $ "source={ expectedSource } " +
775- $ "&storeType={ expectedStoreType } " +
812+ $ "storeType={ expectedStoreType } " +
776813 $ "&containerName={ expectedContainerName } " +
777814 $ "&contentType={ expectedContentType } " +
778815 $ "&contentEncoding={ expectedContentEncoding } " +
779816 $ "{ ( ! string . IsNullOrEmpty ( expectedBlobPath ) ? $ "&blobPath={ expectedBlobPath } " : string . Empty ) } ";
780817
818+ if ( ! string . IsNullOrWhiteSpace ( expectedSource ) )
819+ {
820+ fullQueryString = $ "source={ expectedSource } &{ fullQueryString } ";
821+ }
822+
781823 if ( ! string . IsNullOrWhiteSpace ( queryString ) )
782824 {
783825 fullQueryString = $ "{ queryString . Trim ( '?' , '&' , '/' ) } &{ fullQueryString } ";
0 commit comments