apigee / apigee-deploy-maven-plugin

Apache License 2.0
80 stars 167 forks source link

Support for updating the env values(contains special characters text) from config.json #215

Closed sp5101 closed 1 year ago

sp5101 commented 1 year ago

Hi Team,

When I'm trying to update the value from config.json, its replacing with some extra characters.

here is sample policy.xml, where I want to update the audience value from config.json.


Modified file :


config.json file: "policies":[ { "name": policy.xml", "tokens": [ { "xpath": "/Input", "value": "http://app.testt.com/" } ] } ]

Its replacing the enter input value

http://app.testt.com/

So I tried to update it like string eg: "value": <![TEST[ {"audience" : "http://app.testt.com/"}]]>, due special cart <! > it thrown error. I used the escape cart "/" & "//" to fix it but it escape cart replacing with some other values like "&lt; ".

Could you look into and help me with updating the audience value from config.json file.

Thanks!!

ssvaidyanathan commented 1 year ago

not sure I am following what you are trying to do?

Can you please paste your entire policy code that you have before and after applying the config.json tokenization? So that I can try it out and provide some details if its possible or not or provide another workaround

sp5101 commented 1 year ago

This is the policy code. The audience value will be different for each env, So I'm trying to update the value using config.json file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

getToken test-123 output_aud

Could you suggest a way to update only audience value using config.json? I tried few ways like below

in policy.xml

config.json: "policies":[ { "name": policy.xml", "tokens": [ { "xpath": "/ConnectorCallout/Input", "value": "audience-xsnhux.app " }]}]

in the above case its replacing entire input value instead of audience value.

Another way I tried: in policy.xml

REPLACED_BY_CONFIG_JSON

in config.json "policies":[ { "name": policy.xml", "tokens": [ { "xpath": "/ConnectorCallout/Input", "value": " <![TEST[{"audience" : "audience-xsnhux.app"} ]]>" }]}]

Due to special characters its not updating proper value in policy file.

ssvaidyanathan commented 1 year ago

@sp5101 - I dont see the policy code. Please paste the xml code (before and after)

sp5101 commented 1 year ago

Note sure why its not reflecting. I have attached the screenshot of the policy file. Please let me know if its doesn't work.

image

ssvaidyanathan commented 1 year ago

Why are you trying to change this as part of build? The Connector Callout's Input field can use flow variables. You could just populate a KVM with the appropriate audience value and use that in the policy? Check this doc. With this later if that value changes, you dont have to re-deploy the proxy. By changing the KVM value, it automatically reflects without any downtime and deployment.

Also - why are you using <![TEST[{ instead of <![CDATA[{. Please follow the recommendation in the docs.

If you still cannot use KVM as I recommended above, can you please confirm this for me - In the Input value, you just want to update the entire JSON, correct?

sp5101 commented 1 year ago

yes, I would like to update the entire json

ssvaidyanathan commented 1 year ago

The issue you were seeing is due to the ". You just had to escape that in the config.json

{
    "name": "CC-Logging-Extension.xml",
    "tokens": [
        {
            "xpath": "/ConnectorCallout/Input",
            "value": "<![CDATA[{\"audience\" : \"abcd.app\"}]]>"
        }
    ]
}
sp5101 commented 1 year ago

I tried the above mentioned way. due to the presence of "<" & ">" in the string content , it has been converted into "&lt" & ">". When I download the revision bundle from apigee, the policy file has the original < & > characters.

image

while accessing the api proxy, will "&lt" & ">" values impact the api? how it works, Could you help me on this?

ssvaidyanathan commented 1 year ago

dont think it will have impact. If you download the proxy and it has the correct tags, then you should be good! Can you please try it out on your proxy and let me know?

sp5101 commented 1 year ago

hi @ssvaidyanathan, Its not working. with js script updated the value to make it work.

Thank you!!