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

Add base64Encode/base64Decode filter #2145

Open
jcamiel opened this issue Nov 10, 2023 Discussed in #1921 · 0 comments
Open

Add base64Encode/base64Decode filter #2145

jcamiel opened this issue Nov 10, 2023 Discussed in #1921 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers topic: filters

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Nov 10, 2023

Discussed in #1921

Originally posted by eydun September 12, 2023
My login-request returns a token, which I am able to capture with jsonpath.

But before I can use this token for authorization in the second request, I need to base64 encode it. Is that possible?

Add base64Encode/base64Decode filter.

  • base64Encode: input is in bytes, output is a string
  • base64Decode: input is a string, output is bytes
GET https://foo.com/data.bin
HTTP 200
[Asserts]
bytes base64Encode == "SGVsbG8="
body == "Hello"

Note: to be more useful, we need to have also a filter going from bytes to string for instance utf8Encode/utf8Decode:

  • utf8Encode: input is a string, output is in bytes
  • utf8Decode: input is in bytes, output is a string
GET https://api.foo.com
HTTP 200
[Asserts]
jsonpath "$.data" base64Decode == hex,534756736247383d;
jsonpath "$.data" base64Decode utf8Decode == "Hello"
jsonpath "$.data" utf8Encode base64Encode == "SGVsbG8="

? Do we need a strEncode "encoding"/strDecode "encoding" filter with arbitrary encoding ? Like strEncode "gb-2317"

@jcamiel jcamiel added the enhancement New feature or request label Nov 10, 2023
@jcamiel jcamiel added the good first issue Good for newcomers label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers topic: filters
Projects
None yet
Development

No branches or pull requests

1 participant