Skip to content

enforce valid custom locations SP app object id#6677

Merged
zhoxing-ms merged 1 commit intoAzure:mainfrom
TheOnlyWei:require-oid-for-cl-feature
Sep 28, 2023
Merged

enforce valid custom locations SP app object id#6677
zhoxing-ms merged 1 commit intoAzure:mainfrom
TheOnlyWei:require-oid-for-cl-feature

Conversation

@TheOnlyWei
Copy link
Contributor

@TheOnlyWei TheOnlyWei commented Aug 23, 2023

enforce valid custom locations SP app object id
add .gitignore and test configuration file


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az connectedk8s

General Guidelines

Style errors from the command were already there. Didn't seem style guide was previously enforced, so won't fix these errors here.

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Aug 23, 2023

️✔️Azure CLI Extensions Breaking Change Test
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Aug 23, 2023

Thank you for your contribution! We will review the pull request and get back to you soon.

@TheOnlyWei TheOnlyWei force-pushed the require-oid-for-cl-feature branch from c056352 to 20f923d Compare August 23, 2023 05:04
@TheOnlyWei TheOnlyWei changed the title require SP app object id to enable custom location enforce valid custom locations SP app object id Aug 23, 2023
@TheOnlyWei TheOnlyWei force-pushed the require-oid-for-cl-feature branch 3 times, most recently from 7401894 to cad3189 Compare August 24, 2023 18:36
@TheOnlyWei TheOnlyWei force-pushed the require-oid-for-cl-feature branch 2 times, most recently from 9ebfb6d to b315d43 Compare August 29, 2023 09:35
@TheOnlyWei TheOnlyWei force-pushed the require-oid-for-cl-feature branch 3 times, most recently from 098ac34 to 7d0e5bb Compare September 9, 2023 04:08
Comment on lines +36 to +37
with open(config_path, 'r') as f:
CONFIG = json.load(f)
Copy link
Contributor

Choose a reason for hiding this comment

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

File "/mnt/vss/_work/1/s/src/connectedk8s/azext_connectedk8s/tests/latest/test_connectedk8s_scenario.py", line 29, in
with open(configPath, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/vss/_work/1/s/src/connectedk8s/azext_connectedk8s/tests/latest/config.json'

connectedk8s/azext_connectedk8s/tests/latest/config.json file was used in the testing of CI pipeline, why do you need to remove this file? Could you keep a config file which does not contain sensitive information to make the CI tests pass?

Copy link
Contributor Author

@TheOnlyWei TheOnlyWei Sep 11, 2023

Choose a reason for hiding this comment

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

No this is not possible because this is a live test. You need passwords. Luckily, the code doesn't verify that the password actually works, so I can use a fake password for now just for testing. This might not be the case in the long-run.

Ideally, Azure CLI CI pipeline should have a way to configure secrets for live tests, but I don't know if Azure CLI pipeline actually runs these tests, or ignore missing configurations files related to manual user configurations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Luckily, the code doesn't verify that the password actually works, so I can use a fake password for now just for testing.

OK, this is exactly the way I want to recommend

Copy link
Contributor

@zhoxing-ms zhoxing-ms Sep 12, 2023

Choose a reason for hiding this comment

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

Ideally, Azure CLI CI pipeline should have a way to configure secrets for live tests, but I don't know if Azure CLI pipeline actually runs these tests, or ignore missing configurations files related to manual user configurations.

The CI pipeline will only run tests in playback mode instead of live mode. Regarding the question of whether the CI pipeline can support configuring secrets files, add our CI expert @wangzelin007 to help take a look

Copy link
Member

Choose a reason for hiding this comment

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

We cannot store secrets for security reasons.
If you want run live test successfully, you should create secrets in real time, then complete your test and delete all resources immediately after the test is completed.
This way secrets only exist in memory and will no longer exist after the test is completed, which is the safest.

Copy link
Contributor Author

@TheOnlyWei TheOnlyWei Sep 12, 2023

Choose a reason for hiding this comment

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

@wangzelin007 This is caused by new manual config file added to the live test to begin with. Azure CLI PR pipeline runs and doesn't see config and throws an error because a user needs to create the file. Ideally either there should be an option to ignore these config files or for Azure CLI PR pipeline to support secret configurations. Configurations and code should always be separate, and such configurations should obviously not be committed.

The work-around for now is to put in fake values because the code doesn't validate the password, but that is not a long-term solution if you have to write live tests where credentials are validated.

Does the Azure CLI pipeline only run recorded tests? It tried to execute new test code from this PR, so I assume not everything is recorded. As I did not re-record the test since I was only told to run the live test by owners of this extension, which I am contributing to.

Copy link
Member

Choose a reason for hiding this comment

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

CLI PR will only run recording tests, but we have a pipeline that runs live tests once a week, and you can view the latest test results here.
For your extension, they will only run live tests because of the @live_only decorator.
For live test that requires secret configurations, we recommend that you use az keyvault and az storage commands to create these secrets in real time and destroy them after the test is completed.

Copy link
Contributor Author

@TheOnlyWei TheOnlyWei Sep 13, 2023

Choose a reason for hiding this comment

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

@wangzelin007 The issue with using Azure Key Vault is now you need credentials for Azure Key Vault. Since we don't need real password for the tests currently, temporary real password feature can be implemented for another PR when the need arises.

@zhoxing-ms Are there any other concerns?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I have approved this PR

@zhoxing-ms
Copy link
Contributor

@keystroke Could you please help review this PR agian?

@yanzhudd
Copy link
Contributor

Please resolve the code conflicts.

@TheOnlyWei TheOnlyWei force-pushed the require-oid-for-cl-feature branch from 7d0e5bb to 48b449a Compare September 21, 2023 03:34
add .gitignore and test configuration file
@TheOnlyWei TheOnlyWei force-pushed the require-oid-for-cl-feature branch from 48b449a to 546ae67 Compare September 23, 2023 05:25
@TheOnlyWei
Copy link
Contributor Author

Hi @zhoxing-ms can this be merged?

@zhoxing-ms zhoxing-ms merged commit 8ace62a into Azure:main Sep 28, 2023
@azclibot
Copy link
Collaborator

[Release] Update index.json for extension [ connectedk8s ] : https://dev.azure.com/azclitools/internal/_build/results?buildId=93455&view=results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants