-3

Good day!

How to test code written in Go, which decrypts payload from some API, which I can't change?

Static mock data is not actual, since there is a signature and expiration date inside.

Also have idea to write some API to retrieve fresh payload data, but writing API to test seems to be bad idea.

Can you share ideas to test method of decrypting?

Dazai
  • 49
  • 1
  • 8
  • You might find the answers to [this question](https://stackoverflow.com/q/18970265/11810946) useful. – Brits Mar 24 '22 at 18:35

1 Answers1

0

You can try to create a program that consume such api and save different files.

“Golden files”

Then use it in tests.

Expiration is not a problem if you save the moment that you perform the first request and use it instead “time.Now()”

Tiago Peczenyj
  • 4,387
  • 2
  • 22
  • 35
  • Yeah, I did it at first, but problem is in signature, public key can't verify this even I changed timestamp to actual, because I have to check and validate tag public key and timestamp. So, even I change the timestamp, tests will be fail. – Dazai Mar 25 '22 at 02:55