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

Add UUID validation to rad env update #5758

Merged
merged 9 commits into from
Jun 21, 2023
Merged

Conversation

AaronCrawfis
Copy link
Contributor

@AaronCrawfis AaronCrawfis commented Jun 19, 2023

Description

Today we accept any string for --azure-subscription-id, which can be confusing if a user tries to use a subscription name instead of a subscription ID. We also don't have further downstream checks so this results in a really bad error for users when they do this.

This PR adds CLI validation to make sure the supplied value is a valid UUID (but doesn't check if it's a valid Azure subscription, that'll come later).

There is still work to do to add additional validation, which will come as part of a future PR

Issue reference

Partially addresses #6302

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Adds necessary unit tests for change
  • Adds necessary E2E tests for change
  • Unit tests passing
  • Extended the documentation / Created issue for it

Auto-generated summary

🤖 Generated by Copilot at 6876cc0

Summary

🔄🆕✅

Added a new function to validate Azure subscription ID flags for env update and other commands. Updated tests to cover the validation logic.

Sing, O Muse, of the skillful code review
That brought new order to the update command
And made it heed the azure flag, the true
And valid sign of the subscription's hand.

Walkthrough

  • Import and use uuid.Parse and AzureSubscriptionIdFlag to validate Azure subscription ID flag value in RequireAzureSubscriptionId function (link, link)
  • Use RequireAzureSubscriptionId function in Validate function of update command to ensure valid Azure subscription ID before updating environment (link)
  • Add test case to check error when Azure subscription ID flag value is invalid in Test_Validate function of update_test file (link)
  • Modify existing test case to use valid Azure subscription ID flag value in Test_Validate function of update_test file (link)

@AaronCrawfis AaronCrawfis requested a review from a team as a code owner June 19, 2023 20:43
@github-actions
Copy link

github-actions bot commented Jun 19, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref 6876cc0
Unique ID 751e09e0e2
Image tag pr-751e09e0e2
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-751e09e0e2
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-751e09e0e2
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-751e09e0e2

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting samples functional tests...
⌛ Starting corerp functional tests...
⌛ Starting ucp functional tests...
❌ Failed to install Radius for samples functional test. Please check the logs for more details
❌ samples functional test failed. Please check the logs for more details

@github-actions
Copy link

github-actions bot commented Jun 19, 2023

Test Results

2 629 tests  +1   2 620 ✔️ +1   2m 0s ⏱️ -1s
   236 suites ±0          9 💤 ±0 
       1 files   ±0          0 ±0 

Results for commit 676081e. ± Comparison against base commit 3fd59a0.

This pull request removes 2 and adds 3 tests. Note that renamed tests count towards both.
github.com/project-radius/radius/pkg/armrpc/frontend/controller ‑ TestValidateEtag_IfMatch/ad180077-21c7-44cb-83ef-1ca18c0a89d4
github.com/project-radius/radius/pkg/armrpc/frontend/controller ‑ TestValidateEtag_IfMatch/ad180077-21c7-44cb-83ef-1ca18c0a89d4#01
github.com/project-radius/radius/pkg/armrpc/frontend/controller ‑ TestValidateEtag_IfMatch/0f0ee916-0b68-45e4-9f6c-0f7e3ebdc92c
github.com/project-radius/radius/pkg/armrpc/frontend/controller ‑ TestValidateEtag_IfMatch/0f0ee916-0b68-45e4-9f6c-0f7e3ebdc92c#01
github.com/project-radius/radius/pkg/cli/cmd/env/update ‑ Test_Validate/Update_Env_Command_with_invalid_Azure_subscriptionId_arg

♻️ This comment has been updated with latest results.

@github-actions
Copy link

66.1

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 66.1 %
  • main branch coverage: 66.2 %
  • diff coverage: -.1 %

The coverage result does not include the functional test coverage.

@github-actions
Copy link

github-actions bot commented Jun 19, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref 7ecadfc
Unique ID 14ae42bccb
Image tag pr-14ae42bccb
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-14ae42bccb
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-14ae42bccb
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-14ae42bccb

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting samples functional tests...
⌛ Starting corerp functional tests...
⌛ Starting ucp functional tests...
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
✅ corerp functional tests succeeded

@github-actions
Copy link

github-actions bot commented Jun 19, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref bea492c
Unique ID f544309fd3
Image tag pr-f544309fd3
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-f544309fd3
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-f544309fd3
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-f544309fd3

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting samples functional tests...
⌛ Starting corerp functional tests...
⌛ Starting ucp functional tests...
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
✅ corerp functional tests succeeded

@github-actions
Copy link

66.1

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 66.1 %
  • main branch coverage: 66.2 %
  • diff coverage: -.1 %

The coverage result does not include the functional test coverage.

@AaronCrawfis AaronCrawfis requested a review from youngbupark June 20, 2023 17:21
@github-actions
Copy link

github-actions bot commented Jun 20, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref b84df78
Unique ID e4c075a067
Image tag pr-e4c075a067
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-e4c075a067
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-e4c075a067
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-e4c075a067

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp functional tests...
⌛ Starting samples functional tests...
⌛ Starting corerp functional tests...
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
❌ corerp functional test failed. Please check the logs for more details
⌛ Starting corerp functional tests...
❌ corerp functional test failed. Please check the logs for more details

@github-actions
Copy link

github-actions bot commented Jun 20, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref ea9c336
Unique ID 5aa335fd4b
Image tag pr-5aa335fd4b
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-5aa335fd4b
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-5aa335fd4b
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-5aa335fd4b

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting samples functional tests...
⌛ Starting ucp functional tests...
⌛ Starting corerp functional tests...
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
❌ corerp functional test failed. Please check the logs for more details

@github-actions
Copy link

65.7

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 65.7 %
  • main branch coverage: 65.7 %
  • diff coverage: 0 %

The coverage result does not include the functional test coverage.

@github-actions
Copy link

github-actions bot commented Jun 20, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref ce1a2e4
Unique ID 3f645cd3b7
Image tag pr-3f645cd3b7
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-3f645cd3b7
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-3f645cd3b7
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-3f645cd3b7

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp functional tests...
⌛ Starting samples functional tests...
⌛ Starting corerp functional tests...
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
✅ corerp functional tests succeeded

@github-actions
Copy link

65.7

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 65.7 %
  • main branch coverage: 65.7 %
  • diff coverage: 0 %

The coverage result does not include the functional test coverage.

@github-actions
Copy link

github-actions bot commented Jun 20, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref 6329075
Unique ID f2bb289c55
Image tag pr-f2bb289c55
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-f2bb289c55
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-f2bb289c55
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-f2bb289c55

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp functional tests...
⌛ Starting corerp functional tests...
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
✅ corerp functional tests succeeded

@github-actions
Copy link

65.7

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 65.7 %
  • main branch coverage: 65.7 %
  • diff coverage: 0 %

The coverage result does not include the functional test coverage.

@AaronCrawfis AaronCrawfis requested a review from rynowak June 20, 2023 23:13
return "", err
}

if subscriptionId != "" {

Choose a reason for hiding this comment

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

If subscriptionId is empty, then we need to return error, don't we? I think uuid.Parse can returns error since subscriptionId is empty. So we do not need this if

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah originally I implemented it that way but it caused an issue when the flag was not set: https://github.com/project-radius/radius/actions/runs/5315965610/jobs/9625032925

I have an idea on how to better handle this though, one sec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed an update so validation of the subscriptionId format only occurs if the flags are explicitly set, so it doesn't validate when they're omitted

@github-actions
Copy link

github-actions bot commented Jun 21, 2023

Radius functional test overview

🔍 Go to test action run

Name Value
Repository project-radius/radius
Commit ref 676081e
Unique ID e825b00863
Image tag pr-e825b00863
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.18.0
  • Dapr: 1.10.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.0.0
  • recipe location radiusdev.azurecr.io/test/functional/corerp/recipes/<name>:pr-e825b00863
  • appcore-rp test image location: radiusdev.azurecr.io/appcore-rp:pr-e825b00863
  • ucp test image location: radiusdev.azurecr.io/ucpd:pr-e825b00863

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp functional tests...
⌛ Starting samples functional tests...
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
✅ corerp functional tests succeeded

@github-actions
Copy link

65.7

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 65.7 %
  • main branch coverage: 65.7 %
  • diff coverage: 0 %

The coverage result does not include the functional test coverage.

@AaronCrawfis AaronCrawfis merged commit 3d979bd into main Jun 21, 2023
@AaronCrawfis AaronCrawfis deleted the aacrawfi/uuid-validation branch June 21, 2023 00:33
nithyatsu pushed a commit that referenced this pull request Jun 21, 2023
# Description

Today we accept any string for `--azure-subscription-id`, which can be
confusing if a user tries to use a subscription name instead of a
subscription ID. We also don't have further downstream checks so this
results in a really bad error for users when they do this.

This PR adds CLI validation to make sure the supplied value is a valid
UUID (_but doesn't check if it's a valid Azure subscription, that'll
come later_).

There is still work to do to add additional validation, which will come
as part of a future PR

## Issue reference

<!--
We strive to have all PR being opened based on an issue, where the
problem or feature have been discussed prior to implementation.
-->

Partially addresses #5757

## Checklist

Please make sure you've completed the relevant tasks for this PR, out of
the following list:

* [x] Code compiles correctly
* [x] Adds necessary unit tests for change
* [x] Adds necessary E2E tests for change
* [x] Unit tests passing
* [x] Extended the documentation / Created issue for it

## Auto-generated summary

<!--
GitHub Copilot for docs will auto-generate a summary of the PR
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 6876cc0</samp>

### Summary
🔄🆕✅

<!--
1. 🔄 - This emoji represents the change in the `Validate` function to
use the `RequireAzureSubscriptionId` function instead of directly
getting the flag value.
2. 🆕 - This emoji represents the addition of the new function
`RequireAzureSubscriptionId` to the `cli` package to validate Azure
subscription ID flags for commands.
3. ✅ - This emoji represents the addition and update of test cases for
Azure subscription ID validation in `update_test`.
-->
Added a new function to validate Azure subscription ID flags for `env
update` and other commands. Updated tests to cover the validation logic.

> _Sing, O Muse, of the skillful code review_
> _That brought new order to the update command_
> _And made it heed the azure flag, the true_
> _And valid sign of the subscription's hand._

### Walkthrough
* Import and use `uuid.Parse` and `AzureSubscriptionIdFlag` to validate
Azure subscription ID flag value in `RequireAzureSubscriptionId`
function
([link](https://github.com/project-radius/radius/pull/5758/files?diff=unified&w=0#diff-bf4e917446c73565ee6967f28bdd8e619c0d4fa40b215f195b840c021dd36ce9L25-R28),
[link](https://github.com/project-radius/radius/pull/5758/files?diff=unified&w=0#diff-bf4e917446c73565ee6967f28bdd8e619c0d4fa40b215f195b840c021dd36ce9R264-R278))
* Use `RequireAzureSubscriptionId` function in `Validate` function of
`update` command to ensure valid Azure subscription ID before updating
environment
([link](https://github.com/project-radius/radius/pull/5758/files?diff=unified&w=0#diff-5666f913c4913108ef57c2f23dec3f4b6a4fc6bc653f2b0c51982b9619fb6e12L140-R140))
* Add test case to check error when Azure subscription ID flag value is
invalid in `Test_Validate` function of `update_test` file
([link](https://github.com/project-radius/radius/pull/5758/files?diff=unified&w=0#diff-c8b9a3315a934ca0d8e0b750b2872603b1c504239f5d310251e87e5fb6a8e4a2L68-R78))
* Modify existing test case to use valid Azure subscription ID flag
value in `Test_Validate` function of `update_test` file
([link](https://github.com/project-radius/radius/pull/5758/files?diff=unified&w=0#diff-c8b9a3315a934ca0d8e0b750b2872603b1c504239f5d310251e87e5fb6a8e4a2L78-R87))
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.

4 participants