I have a flow that has the Salesforce create connector, the Munit test that references the flow Runs fine locally. But when I try to deploy them to the CloudHub using the Azure Devops CI/CD pipeline throws error like
WARN 2022-04-07 23:41:54,103 [[MuleRuntime].uber.04: [mule-salesforce-sys].salesforce-Opportunity-create-flow/processors/3.ps.BLOCKING @3c7baec] org.mule.extension.salesforce.internal.connection.provider.BasicConnectionProvider: Couldn't obtain access token because an exception has occurred. Runtime to handle the ConnectionException. Root exception was: Invalid status code: 400, response body: {"error":"invalid_client","error_description":"invalid client credentials"}
.
org.mule.runtime.extension.api.exception.ModuleException: Invalid status code: 400, response body: {"error":"invalid_client","error_description":"invalid client credentials"}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Invalid status code: 400, response body: {"error":"invalid_client","error_description":"invalid client credentials"}
But before I created the Munit tests I deployed the flow to the CloudHub and there was no issues or error. I can still access the endpoint. After adding the Munit tests and deploying it throws error. All the credentials are stored in the Pipeline Variables..
And the Munit test
<munit:test name="salesforce-sys-implementation-test-suite-salesforce-Opportunity-create-flowTest" doc:id="c9779a45-00fe-4e08-b3e7-2580e68352ef" description="Test">
<munit:behavior>
<munit-tools:mock-when doc:name="Mock when" doc:id="a2ff9717-a4ee-4bea-9caf-9e3d5fe591b7" processor="flow">
<munit-tools:with-attributes >
<munit-tools:with-attribute whereValue="post:\opportunity:application\json:salesforce-system-api-config" attributeName="name" />
</munit-tools:with-attributes>
<munit-tools:then-return >
<munit-tools:payload value="#{}" mediaType="application/json" encoding="UTF-8" />
</munit-tools:then-return>
</munit-tools:mock-when>
</munit:behavior>
<munit:execution >
<munit:set-event doc:name="Set Event" doc:id="4c21ba83-a2d8-47f7-a327-33a772f980c6" >
<munit:payload value='{
"name": "X",
"SowGenerationStage": "SOW Requested",
"dateOfFirstContact": "2022-03-28",
"closeDate": "2022-03-28",
"SowRequestDate": "2022-03-28T12:48:16Z",
"accountId": "001T7IAM",
"contact": "003U0",
"leadSource": "Project Management",
"recordTypeId": "012U0000000QBXWIA4",
"serviceType": "SPR",
"priceBook2ID": "01s",
"stageName": "Discover"
}' mediaType="application/json" />
</munit:set-event>
<flow-ref doc:name="Flow-ref to salesforce-Opportunity-create-flow" doc:id="3c3d043f-f1ad-4b8d-9290-d407400d14a6" name="salesforce-Opportunity-create-flow"/>
</munit:execution>
<munit:validation >
<munit-tools:assert-that doc:name="Assert that Not Null Response" doc:id="da165ba2-619f-462e-8278-e66ee771cb08" is="#MunitTools::notNullValue()" expression="#payload.Id"/>
</munit:validation>
</munit:test>
Hello,
Please select the correct processor in MUnit Mock component. I am sure It will work. I checked your attachment it was wrong.
Sample below: Working