Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beejones/service request must show body in debug #287

Merged
merged 12 commits into from
Jan 15, 2025
14 changes: 6 additions & 8 deletions src/utils/ServiceRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,16 @@ export class ServiceRequest<T> {
}
}

Logger.debug(`Request:`, this.logContext, JSON.stringify(requestWithoutAuth, null, 2));
this.query = queryParams(request, this.logContext);

try {
this.body = request.body.json();
} catch (exception) {
this.error = {
errorMessage: `${this.logContext.getBaseScope()}: No valid JSON request for ${this.logContext.getFormattedScopeString()}`,
};
this.success = false;
return;
Logger.info("No JSON body found", this.logContext);
DomAyre marked this conversation as resolved.
Show resolved Hide resolved
}

requestWithoutAuth.body = this.body;
Logger.debug(`Request:`, this.logContext, JSON.stringify(requestWithoutAuth, null, 2));
this.query = queryParams(request, this.logContext);

this.success = true;
}

Expand Down
33 changes: 0 additions & 33 deletions test/system-test/test_unwrapkey.py

This file was deleted.

8 changes: 4 additions & 4 deletions test/unit-test/utils/ServiceRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ describe("Test ServiceRequest properties", () => {
}));
settingsPolicyMap.set("settings_policy", settingsPolicyValue);


// Mock Logger.debug
const debugSpy = jest.spyOn(console, "log").mockImplementation(() => true);



// Act
const serviceRequest =
new ServiceRequest<void>(logContext, <any>request);
// Dump all messages received by debugSpy
console.dir(debugSpy.mock.calls, { depth: null });

// Assert
Expand Down Expand Up @@ -128,7 +126,9 @@ describe("Test ServiceRequest properties", () => {
' "route": "/app/key",\n' +
' "url": "/app/key",\n' +
' "params": {},\n' +
' "body": {}\n' +
' "body": {\n' +
' "key": "value"\n' +
' }\n' +
'}';
expect(debugSpy).toHaveBeenCalledWith(expectedLogMessageWithoutBearer);

Expand Down
Loading