Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public Task Configure(string endpointName, EndpointConfiguration configuration,

var transportConfig = configuration.UseTransport<LearningTransport>();
transportConfig.StorageDirectory(ConnectionString);
transportConfig.NoPayloadSizeRestriction();

return Task.FromResult(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,49 @@ await Define<Context>()
Assert.AreEqual(0, body.Length);
}

[Test]
public async Task Should_not_get_an_empty_audit_message_body_when_body_is_above_loh_but_below_max_body_size()
{
//Arrange
SetSettings = settings => settings.MaxBodySizeToStore = 2* MAX_BODY_SIZE_BIGGER_THAN_LOH;

byte[] body = null;

//Act
await Define<Context>()
.WithEndpoint<FatMessageEndpoint>(c => c.When(b => b.SendLocal(
new BigFatMessage // An endpoint that is configured for audit
{
BigFatBody = new byte[MAX_BODY_SIZE_BIGGER_THAN_LOH]
}))
)
.Done(
async c =>
{
if (c.MessageId == null)
{
return false;
}

var result = await this.TryGetSingle<MessagesView>("/api/messages", r => r.MessageId == c.MessageId);
MessagesView auditMessage = result;
if (!result)
{
return false;
}

body = await this.DownloadData(auditMessage.BodyUrl);

return true;
})
.Run();

//Assert
Assert.IsNotNull(body);
}

const int MAX_BODY_SIZE = 20536;
const int MAX_BODY_SIZE_BIGGER_THAN_LOH = 87000;

class FatMessageEndpoint : EndpointConfigurationBuilder
{
Expand Down
8 changes: 7 additions & 1 deletion src/ServiceControl.Audit/Auditing/GetBodyByIdApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async Task<HttpResponseMessage> TryFetchFromStorage(HttpRequestMessage request,
content.Headers.ContentLength = result.BodySize;
response.Headers.ETag = new EntityTagHeaderValue($"\"{result.Etag}\"");
response.Content = content;
return response;
}

return request.CreateResponse(HttpStatusCode.NotFound);
Expand All @@ -70,7 +71,12 @@ async Task<HttpResponseMessage> TryFetchFromIndex(HttpRequestMessage request, st
{
return request.CreateResponse(HttpStatusCode.NoContent);
}


if (message.Body == null)
{
return request.CreateResponse(HttpStatusCode.NotFound);
}

var response = request.CreateResponse(HttpStatusCode.OK);
var content = new StringContent(message.Body);
content.Headers.ContentType = MediaTypeHeaderValue.Parse(message.ContentType);
Expand Down