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
refactor(cypress): read creds from env instead of hardcoding the path #4430
Conversation
The base branch was changed.
The base branch was changed.
29304fd
to
74a9e4d
Compare
…to-env * 'main' of github.com:juspay/hyperswitch: ci(postman): Fix Adyen postman collection (#4459) docs(cypress): Update Cypress README Documentation (#4380) Refactor(core): make save_payment_method as post_update_tracker trait function (#4307) refactor(connector): pass optional browser_info to stripe for increased trust (#4374)
// readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature | ||
// it is best to use then() to handle the response within the same block of code | ||
cy.readFile(globalState.get("connectorAuthFilePath")).then((jsonContent) => { | ||
const authDetails = getValueByKey(JSON.stringify(jsonContent), globalState.get("connectorId")); | ||
createConnectorBody.connector_account_details = authDetails; | ||
cy.request({ | ||
method: "POST", | ||
url: `${globalState.get("baseUrl")}/account/${merchantId}/connectors`, | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
"api-key": globalState.get("adminApiKey"), | ||
}, | ||
body: createConnectorBody, | ||
}).then((response) => { | ||
logRequestId(response.headers['x-request-id']); | ||
|
||
if (response.status === 200) { | ||
expect(globalState.get("connectorId")).to.equal(response.body.connector_name); | ||
} else { | ||
cy.task('cli_log', "response status -> " + JSON.stringify(response.status)); | ||
cy.task('cli_log', "res body -> " + JSON.stringify(response.body)); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConnectorAuthDetails
in line 29 reads the content from the file and stores within that variable.
getValueByKey()
takes the content of the file and the key (the connector name) and returns the respective connector auth details.
Since we now read from the env, we do not have any method to store the content. Cypress natively supports cy.readFile
which is again, asynchronous in nature, returns an Object (promise). We can only parse that Object within .then()
and read it.
With that, it makes it necessary for us to move the entire flow within cy.readFile()
[Docs: https://docs.cypress.io/api/commands/readfile]
…to-env * 'main' of github.com:juspay/hyperswitch: feat: add an api for toggling extended card info feature (#4444)
@pixincreate Can you update the readme for this. So that contributors can know how to configure auth file. |
Edit: #4505 |
* 'main' of github.com:juspay/hyperswitch: refactor(cypress): read creds from env instead of hardcoding the path (#4430) ci: fix paypal postman tests (#4501) Refactor(core): remove payment_method_id from RouterData struct (#4485) fix(euclid_wasm): connector config wasm metadata update (#4460) chore(version): 2024.04.30.0 feat(user): add single purpose token and auth (#4470) feat: stripe connect integration for payouts (#2041) feat(router): handle authorization for frictionless flow in external 3ds flow (#4471) feat(FRM): Revise post FRM core flows (#4394) feat(router): send poll_config in next_action of confirm response for external 3ds flow (#4443) chore(version): 2024.04.29.0 feat(connector): [CRYPTOPAY] Report underpaid/overpaid amount in outgoing webhooks (#4468) feat(users): use cookie for auth (#4434) refactor(scheduler): join frequency and count in `RetryMapping` (#4313) refactor(required_fields): change required fields for billing address (#4258) refactor(access_token): use `merchant_connector_id` for storing access token (#4462) chore(version): 2024.04.26.0 chore(postman): update Postman collection files
Type of Change
Description
ConnectorAuthDetails
for reading it through envUsage
Additional Changes
Motivation and Context
There has been many occurrences where developers accidentally exposed the path to
creds.json
from their PC (although it is not too much of a security risk, it still poses a significant risk on surface level). To avoid that from happening again in future, this measure has been taken.How did you test it?
Followed the Usage section mentioned above and ran the tests, they ran fine without any issues:
Checklist
cargo +nightly fmt --all
cargo clippy