cloudfoundry / cli

The official command line client for Cloud Foundry
https://docs.cloudfoundry.org/cf-cli
Apache License 2.0
1.75k stars 928 forks source link

displaybody should respect new line #2981

Open h0nIg opened 3 weeks ago

h0nIg commented 3 weeks ago

Description of the Change

REQUEST and RESPONSE should behave the same with CF_TRACE=true and CF_TRACE=testfile. even across request logger.

https://github.com/cloudfoundry/cli/blob/fa795ba5bea096a99e38e90a25eb405e4f1e5308/util/ui/request_logger_terminal_display.go#L27 https://github.com/cloudfoundry/cli/blob/fa795ba5bea096a99e38e90a25eb405e4f1e5308/util/ui/request_logger_file_writer.go#L32

CLI stdout

Authenticating...
REQUEST: [2024-07-02T13:42:02Z]
POST /oauth/token HTTP/1.1
Host: login.xxxxx
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Connection: close
Content-Type: application/x-www-form-urlencoded
User-Agent: cf8/8.7.10+5b7ce3c.2024-04-04 (go1.22.1; amd64 linux)
[PRIVATE DATA HIDDEN]

RESPONSE: [2024-07-02T13:42:02Z]
HTTP/1.1 200 OK

CLI file output

REQUEST: [2024-07-02T11:14:36Z]
POST /oauth/token HTTP/1.1
Host: login.xxx
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Connection: close
Content-Type: application/x-www-form-urlencoded
User-Agent: cf8/8.7.10+5b7ce3c.2024-04-04 (go1.22.1; amd64 linux)
[PRIVATE DATA HIDDEN]
RESPONSE: [2024-07-02T11:14:36Z]
HTTP/1.1 200 OK

Why Is This PR Valuable?

proper parsing across all redaction code (uaa, cloud controler, ...) https://github.com/cloudfoundry/cli/blob/fa795ba5bea096a99e38e90a25eb405e4f1e5308/api/cloudcontroller/wrapper/request_logger.go#L116 https://github.com/cloudfoundry/cli/blob/fa795ba5bea096a99e38e90a25eb405e4f1e5308/api/uaa/wrapper/request_logger.go#L104

uaa:

REQUEST: [2024-07-02T11:14:36Z]
POST /oauth/token HTTP/1.1
Host: login.xxx
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Connection: close
Content-Type: application/x-www-form-urlencoded
User-Agent: cf8/8.7.10+5b7ce3c.2024-04-04 (go1.22.1; amd64 linux)
[PRIVATE DATA HIDDEN]
RESPONSE: [2024-07-02T11:14:36Z]
HTTP/1.1 200 OK

cloud controller (including newline)

REQUEST: [2024-07-02T11:14:28Z]
GET / HTTP/1.1
Host: api.xxx
Accept: application/json
Content-Type: application/json
User-Agent: cf8/8.7.10+5b7ce3c.2024-04-04 (go1.22.1; amd64 linux)
[application/json Content Hidden]

RESPONSE: [2024-07-02T11:14:28Z]
HTTP/1.1 200 OK

How Urgent Is The Change?

Not urgent

joaopapereira commented 3 weeks ago

Hey thanks for the PR do you mind rebasing your PR?

h0nIg commented 3 weeks ago

@joaopapereira done, unit tests green but still some flaky integration tests, any idea?


  [FAILED] Got stuck at:

  Waiting for:
      APP2-82d5acd4-30b8-4cc2-6f96-1835209e208b\s+e231607e-16bb-4314-74d0-034adc03bc47\s+create succeeded\s*\n
  In [It] at: /__w/cli/cli/integration/v7/isolated/service_command_test.go:179 @ 07/04/24 08:46:09.628
h0nIg commented 1 week ago

@joaopapereira @gururajsh may i ask to re-trigger the flapping "Tests / Integration tests / MIN CAPI / run-integration-tests"?

Do you see any show stoppers to get this merged?