Victor Lau
01/26/2023, 12:04 AM500
request mismatch from Pact. I'm aware that my expected request is not the same, but I am trying to write an SDK contract as a demo and reverse-engineering the request for my test setup. Deleted some actual data for privacy purposes.
"{\"error\":\"Request-Mismatch : HttpRequest { method: \\\"POST\\\", path: \\\"/\\\", query: Some({\\\"api-version\\\": [\\\"1.0\\\"]}), headers: Some({\\\"user-agent\\\": [\\\"\\\"], \\\"content-length\\\": [\\\"848\\\"], \\\"connection\\\": [\\\"Keep-Alive\\\"], \\\"authorization\\\": [\\\"Bearer Access-Token\\\"], \\\"host\\\": [\\\"127.0.0.1:59176\\\"], \\\"expect\\\": [\\\"100-continue\\\"], \\\"content-type\\\": [\\\"application/json\\\"], \\\"x-mt-secondaryid\\\": [\\\"\\\"]}), body: Present", Some(ContentType { main_type: \\\"application\\\", sub_type: \\\"json\\\", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {} }, generators: Generators { categories: {} } }\"}"
Victor Lau
01/26/2023, 12:04 AMVictor Lau
01/26/2023, 9:52 PMMatt (pactflow.io / pact-js / pact-go)
Victor Lau
01/26/2023, 11:33 PMVictor Lau
01/26/2023, 11:35 PMExpected '{\"eventMessageId\":{\"pact:matcher:type\":\"type\",\"value\":\"string\"},
Victor Lau
01/26/2023, 11:35 PM"eventMessageId\":\"d5f8868f-baa1-4f6c-9166-2056c374d6f5\"
I'm assuming that it works, but the error just says my entire body doesn't matchMatt (pactflow.io / pact-js / pact-go)
Victor Lau
01/26/2023, 11:45 PM_pact.UponReceiving("a POST request to create an Audit record").
Given("Transformed Audit Request Model").
WithRequest(<http://HttpMethod.Post|HttpMethod.Post>, "/auditing/emitter/api/audit").
WithQuery("api-version", "1.0").
WithHeader("user-agent", "UserAgent").
WithHeader("authorization", "Bearer Access-Token").
WithHeader("content-length", "848").
WithHeader("content-type", "application/json").
WithHeader("x-mt-secondaryid", Guid.Empty.ToString()).
WithHeader("expect", "100-continue").
WithHeader("connection","Keep-Alive").
WithJsonBody(new
{
EventMessageId = Match.Type("string"),
SessionId = auditRequestModel.SessionId,
SourceId = auditRequestModel.SourceId,
SecretId = auditRequestModel.SecretId,
UserId = auditRequestModel.UserId,
UserName = auditRequestModel.UserName,
AssetId = auditRequestModel.AssetId,
EventTypeId = auditRequestModel.EventTypeId,
EventDateTime = auditRequestModel.EventDateTime,
RawMessage = auditRequestModel.RawMessage,
Tags = auditRequestModel.Tags,
AnalyticData = auditRequestModel.AnalyticData
}).
WillRespond().WithStatus(HttpStatusCode.Accepted);
Victor Lau
01/26/2023, 11:46 PM_pact = Pact.V3("Secret Server API", "Auditing Platform Service", new PactConfig()
{
PactDir = $"{Directory.GetParent(Directory.GetCurrentDirectory())}",
LogLevel = PactLogLevel.Debug
}).WithHttpInteractions();
var auditRequestModel = _auditTransformer.TransformIEventQueueToAuditModel(displayItem);
Then I have some substitutes in-between but they're just to make the class instantiate properlyVictor Lau
01/26/2023, 11:47 PMEventMessageId
because my TransformIEventQueueToAuditModel adds a random Guid to the object before sending. Hence the mocked and the actual differ on that specific fieldVictor Lau
01/27/2023, 5:43 AMVictor Lau
01/27/2023, 6:27 AM[BodyMismatch { path: "$", expected:
Some(b"[\"analyticData\",\"assetId\",\"eventDateTime\",\"eventMessageId\",\"eventTypeId\",\"rawMessage\",\"secretId\",\"sessionId\",\"sourceId\",\"tags\",\"userId\",\"userName\"]"),
actual: Some(b"[\"assetId\",\"eventDateTime\",\"eventMessageId\",\"eventTypeId\",\"rawMessage\",\"secretId\",\"sourceId\",\"tags\",\"userId\",\"userName\"]"),
mismatch: "Expected a Map with keys analyticData, assetId, eventDateTime, eventMessageId, eventTypeId, rawMessage, secretId, sessionId, sourceId, tags, userId, userName but received one with keys assetId, eventDateTime, eventMessageId, eventTypeId, rawMessage, secretId, sourceId, tags, userId, userName" }]
Victor Lau
01/27/2023, 6:28 AMMatt (pactflow.io / pact-js / pact-go)
analyticData
and sessionId
Victor Lau
01/30/2023, 4:32 AMVictor Lau
01/30/2023, 4:32 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)