Skip to content

Commit

Permalink
Merge pull request #889 from wsugarman/more-vnext-storage-fixes
Browse files Browse the repository at this point in the history
Fix TableClient.Uri When Endpoint Contains SAS Tokens
  • Loading branch information
davidmrdavid committed Apr 14, 2023
2 parents 4cefd74 + 34e4a2a commit 2ce73c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public void GetUri_ServiceEndpoint()
[TestMethod]
public void GetUri_TableEndpoint()
{
var client = new TableClient(new Uri("https://foo.table.core.windows.net/bar"));
TableClient client;

client = new TableClient(new Uri("https://foo.table.core.windows.net/bar"));
Assert.AreEqual(new Uri("https://foo.table.core.windows.net/bar"), client.GetUri());

client = new TableClient(new Uri("https://foo.table.core.windows.net/bar?sv=2019-12-12&ss=t&srt=s&sp=rwdlacu&se=2020-08-28T23:45:30Z&st=2020-08-26T15:45:30Z&spr=https&sig=mySig&tn=bar"));
Assert.AreEqual(new Uri("https://foo.table.core.windows.net/bar"), client.GetUri());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ static class TableClientExtensions
}

Uri? endpoint = GetEndpointFunc(tableClient);
return endpoint != null ? new TableUriBuilder(endpoint) { Tablename = tableClient.Name }.ToUri() : null;
return endpoint != null
? new TableUriBuilder(endpoint) { Query = null, Sas = null, Tablename = tableClient.Name }.ToUri()
: null;
}

static readonly Func<TableClient, Uri?> GetEndpointFunc = CreateGetEndpointFunc();
Expand Down

0 comments on commit 2ce73c5

Please sign in to comment.