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

Change response data in test script #4809

Closed
coder-free opened this issue Jul 11, 2018 · 2 comments
Closed

Change response data in test script #4809

coder-free opened this issue Jul 11, 2018 · 2 comments

Comments

@coder-free
Copy link

I want decrypt the response data.
For example,
response data from server is:
image
and test script set to this:
image
and logged the "decryptedData" value is decrypted. But the showing response data is not decrypt.

@numaanashraf
Copy link
Member

@zfavourite99 Thanks for the feature suggestion.

@numaanashraf numaanashraf changed the title how to change the response data in test script Change response data in test script Jul 11, 2018
@vkaegis vkaegis added the console label Nov 8, 2018
@saswatds saswatds added this to the runtime-11 milestone Jun 27, 2019
@codenirvana codenirvana modified the milestones: runtime-11, runtime-13 Sep 3, 2019
@codenirvana
Copy link
Member

@zfavourite99 You can achieve this by using the new Visualizers feature added in the lastest Postman app v7.7.

Example:

pm.visualizer.set(`
<div id="response"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script>

<script>
pm.getData((err, data) => {
    var ciphertext = data.response.data;
    var bytes  = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret-key');
    var plaintext = bytes.toString(CryptoJS.enc.Utf8);
    
    var output = JSON.stringify({ ciphertext, plaintext }, null, 2).replace(/\\n/g, '<br>');

    document.getElementById("response").innerHTML = output;
});
</script>

`, {
    response: pm.response.json()
});

Screenshot 2019-09-17 at 6 01 36 PM

Learn more about visualizers: https://learning.getpostman.com/docs/postman/sending_api_requests/visualizer/

Let me know if that fixes your issue!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants