Better errors from Download: Make GetFileSasUrl nullable (#3229)

This allows us to generate 404s when someone attempts to download from a non-existent container. At the moment we generate a 500 which isn't useful, or very good looks-wise.
This commit is contained in:
George Pollard
2023-06-28 10:24:32 +12:00
committed by GitHub
parent 4b437533f0
commit 7c0dc7b65e
7 changed files with 107 additions and 26 deletions

View File

@ -55,6 +55,22 @@ public abstract class DownloadTestBase : FunctionTestBase {
Assert.Equal(ErrorCode.INVALID_REQUEST.ToString(), err.Title);
}
[Fact]
public async Async.Task Container_NotFound_Generates404() {
var req = TestHttpRequestData.Empty("GET");
// this container won't exist because we haven't explicitly created it
var url = new UriBuilder(req.Url) { Query = "container=xxx&filename=yyy" }.Uri;
req.SetUrl(url);
var func = new Download(Context);
var result = await func.Run(req);
Assert.Equal(HttpStatusCode.NotFound, result.StatusCode);
var err = BodyAs<ProblemDetails>(result);
Assert.Equal(ErrorCode.INVALID_CONTAINER.ToString(), err.Title);
}
[Fact]
public async Async.Task Download_RedirectsToResult_WithLocationHeader() {
// set up a file to download