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

AAP-30986: Support deletion of WCA API_KEY from Admin Portal (Frontend) #1333

Merged
merged 10 commits into from
Oct 11, 2024

Conversation

mabulgu
Copy link
Contributor

@mabulgu mabulgu commented Oct 3, 2024

Jira Issue: https://issues.redhat.com/browse/AAP-30986

Description

Please see the Jira issue for details. Note that this issue splitted into two: frontend & backend. This PR includes the FE changes work.

Testing

Follow the following steps. Do not commit anything by mistake as you will need to de-comment some places in the code.

Steps to test

  1. Go to ansible_ai_connect_admin_portal/src/ModelSettingsOverview.tsx:288
  2. Comment the related part (the delete button)
  3. Run npm start Open the link in browser tab. This is the mocked mode.
  4. Test out the deletion. You might need to play with the mock API here (ansible_ai_connect_admin_portal/config/webpack.mock.api.keys.ts:66) to simulate an error.
  5. Revert your changes and dont commit/push them by mistake.
  6. Run the npm run test command to make sure all tests pass.

Scenarios tested

  • Deletion with success
  • Deletion with failure

Production deployment

  • This code change is ready for production on its own
  • This code change requires the following considerations before going to production: The backend part of this code should be completed and done. See AAP-32688.

@mabulgu mabulgu requested a review from manstis October 3, 2024 11:02
Copy link

github-actions bot commented Oct 3, 2024

# npm audit report

rollup  <2.79.2
Severity: high
DOM Clobbering Gadget found in rollup bundled scripts that leads to XSS - https://github.com/advisories/GHSA-gcx4-mw62-g8wm
fix available via `npm audit fix`
node_modules/rollup

1 high severity vulnerability

To address all issues, run:
  npm audit fix

@@ -10,9 +10,11 @@
"APIKey": "IBM Cloud API Key",
"APIKeyTooltip": "Used to authenticate with IBM watsonx Code Assistant.",
"APIKeyDescription": "The API Key for IBM watsonx Code Assistant.",
"APIKeyDeletionConfirmation": "Are you sure you want to delete your IBM Cloud API Key?",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to ask about this text to Marty once I start the backend part. For now since we dont see it, pls ignore the product owner approval. I will get the related approvals.

@manstis
Copy link
Contributor

manstis commented Oct 3, 2024

Hi @mabulgu

I had a quick look. Was you planning on writing tests too?

I also note that the JIRA states:

Deleting the API_KEY should also delete the MODEL_ID as having one set without the other is an indeterminate system state.

I don't see anything in your mocked backend to support this... it might be that you need to combine the two mock backends into a single file so that "Key deletion" can access "Model" for the origanisation:

Let me know your answers then I'll review this PR.

@mabulgu
Copy link
Contributor Author

mabulgu commented Oct 3, 2024

Hi @mabulgu

I had a quick look. Was you planning on writing tests too?

I also note that the JIRA states:

Deleting the API_KEY should also delete the MODEL_ID as having one set without the other is an indeterminate system state.

I don't see anything in your mocked backend to support this... it might be that you need to combine the two mock backends into a single file so that "Key deletion" can access "Model" for the origanisation:

Let me know your answers then I'll review this PR.

@manstis I implemented the key -model id deletion relation

@mabulgu
Copy link
Contributor Author

mabulgu commented Oct 3, 2024

Code coverage complains because there is no tests for the parts that I not fully comemnted. I changed the strategy by making the delete button hidden so that I can make it visible and run tests against it. Working on this right now. jfyi

Copy link

github-actions bot commented Oct 9, 2024

# npm audit report

cookie  <0.7.0
cookie accepts cookie name, path, and domain with out of bounds characters - https://github.com/advisories/GHSA-pxg6-pf52-xh8x
fix available via `npm audit fix`
node_modules/cookie
  express  3.0.0-alpha1 - 4.21.0 || 5.0.0-alpha.1 - 5.0.0
  Depends on vulnerable versions of cookie
  node_modules/express

2 low severity vulnerabilities

To address all issues, run:
  npm audit fix

@mabulgu
Copy link
Contributor Author

mabulgu commented Oct 9, 2024

@manstis ready for another round of review

@mabulgu
Copy link
Contributor Author

mabulgu commented Oct 10, 2024

My Failure case aims a 404 error but I realized in the backend we do return 400 for those. Those changes will be included in my backend PR so please consider them as 404 for now. JFYI.

Copy link
Contributor

@manstis manstis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good @mabulgu

A few comments that should probably be addressed.

@manstis
Copy link
Contributor

manstis commented Oct 11, 2024

@mabulgu

My Failure case aims a 404 error but I realized in the backend we do return 400 for those. Those changes will be included in my backend PR so please consider them as 404 for now. JFYI.

For a "successful" operation with no content (i.e. DELETE) a 204 may be best.

Copy link

Copy link
Contributor

@manstis manstis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Thanks @mabulgu

@mabulgu mabulgu merged commit 2f458dd into main Oct 11, 2024
11 checks passed
@mabulgu mabulgu deleted the task/AAP-30986 branch October 11, 2024 15:17
@mabulgu
Copy link
Contributor Author

mabulgu commented Oct 11, 2024

Thanks @manstis for your help and reviews!

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

Successfully merging this pull request may close these issues.

2 participants