-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[#7706] Platform: Edit backup config credentials. #8050
[#7706] Platform: Edit backup config credentials. #8050
Conversation
…-db into 7706-Edit-Configs
This pull request introduces 2 alerts when merging bd965bc into 9d5751c - view on LGTM.com new alerts:
|
assertOk(result); | ||
assertEquals(data, CustomerConfig.get(configUUID).data); | ||
} | ||
|
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.
Required to add more test cases.
- testcase to edit not used config. It should allow all fields to edit.
- testcase to edit in the used config should config with limited fields.
- In used config with all field edit. API should give an error.
- Invalid Data, Content, and Invalid configured. you can add 1 test case for each or add one testcase and cover all 3 senario.
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.
@jaydeepkumara for both used and unused configs, editable fields are the same I believe. ( at least the current implementation of UI behaves like that. @nishantSharma459 confirm )
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.
ok.
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.
In Test plan clearly mention that we just have tested end to end for AWS.
} | ||
CustomerConfig customerConfig = CustomerConfig.get(customerUUID, configUUID); | ||
if (customerConfig == null) { | ||
return ApiResponse.error(BAD_REQUEST, "Invalid configUUID: " + configUUID); |
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.
Invalid Customer configuration UUID.
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.
Consistent with the delete API response.
Tested below scenario.
|
…-db into 7706-Edit-Configs
…-db into 7706-Edit-Configs
This pull request introduces 2 alerts when merging 88e5728 into e63ce11 - view on LGTM.com new alerts:
|
|
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.
Approved with an assumption that thorough testing was done before submitting the PR for review, including possible regression.
Suggest getting another pair of eyes as well, especially on java part as I haven't assessed it.
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.
Still some comments to finalize the BE part.
managed/src/main/java/com/yugabyte/yw/controllers/CustomerConfigController.java
Outdated
Show resolved
Hide resolved
} | ||
CustomerConfig config = CustomerConfig.get(configUUID); | ||
JsonNode data = Json.toJson(formData.get("data")); | ||
if (data != null && data.get("BACKUP_LOCATION") != null) { |
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.
Please extract "BACKUP_LOCATION" into a constant or use CustomerConfigValidator.BACKUP_LOCATION_FIELDNAME
.
P.S. BTW, maybe it is even better to extract these field names into a separate file if we going to use them not only inside CustomerConfigValidator
.
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.
we are using the string instead of constants lot of places. Including other tests and utils file for masking. I will create another issue to fix these separately.
managed/src/main/java/com/yugabyte/yw/controllers/CustomerConfigController.java
Show resolved
Hide resolved
@Test | ||
public void testEditInUseStorageConfig() { | ||
ObjectNode bodyJson = Json.newObject(); | ||
JsonNode data = Json.parse("{\"BACKUP_LOCATION\": \"test\", \"ACCESS_KEY\": \"A-KEY\", " + |
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.
Putting strings here instead of somewhere defined constants may give us some problems later if someone decides to rename one of these fields. I suggest to create/use Java constants.
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.
Yeah, we are using the string instead of constants lot of places. Including other tests and utils file for masking. I will create another issue to fix these separately.
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.
OK, this works for me.
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.
One serious issue in BE code. Other things look good.
managed/src/main/java/com/yugabyte/yw/controllers/CustomerConfigController.java
Show resolved
Hide resolved
return isStrictlySensitiveField(key) || (value == null) ? MASKED_FIELD_VALUE | ||
: value.replaceAll(maskRegex, "*"); | ||
return isStrictlySensitiveField(key) || value.length() < 5 | ||
|| (value == null) ? MASKED_FIELD_VALUE : value.replaceAll(maskRegex, "*"); |
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.
No-no-no. If you have this in such variant then you don't have a test case for this. IIRC, boolean operations are executed from left to right order. So if you have value=null
, you will get NPE here as value.length() < 5
is executed before (value == null)
.
Update here and update tests to control this case.
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.
Oops!! Yeah, did not check the last condition. Will update and add a test case too.
@Test | ||
public void testEditInUseStorageConfig() { | ||
ObjectNode bodyJson = Json.newObject(); | ||
JsonNode data = Json.parse("{\"BACKUP_LOCATION\": \"test\", \"ACCESS_KEY\": \"A-KEY\", " + |
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.
OK, this works for me.
This pull request introduces 2 alerts when merging ee6a95d into ba3f65e - view on LGTM.com new alerts:
|
) Description: Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups. This change should be implemented for all three storage configs: AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey GCP: Allow editing GCS Credentials [Do not allow editing bucket name] Azure: Allow editing Azure SAS token [Do not allow editing Container URL] Test Plan: 1. Hit the config button from the SideNav. 2. Click on Backup Tab and then hit the amazon s3 tab. 3. Create a backup config for s3. 4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button. 5. Click on the Edit Configuration button. 6. AWS access credentials should be editable. Do the same for the rest of the configs. Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara
) Description: Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups. This change should be implemented for all three storage configs: AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey GCP: Allow editing GCS Credentials [Do not allow editing bucket name] Azure: Allow editing Azure SAS token [Do not allow editing Container URL] Test Plan: 1. Hit the config button from the SideNav. 2. Click on Backup Tab and then hit the amazon s3 tab. 3. Create a backup config for s3. 4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button. 5. Click on the Edit Configuration button. 6. AWS access credentials should be editable. Do the same for the rest of the configs. Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara
) * [#7706] Platform: Edit backup config credentials. (#8050) Description: Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups. This change should be implemented for all three storage configs: AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey GCP: Allow editing GCS Credentials [Do not allow editing bucket name] Azure: Allow editing Azure SAS token [Do not allow editing Container URL] Test Plan: 1. Hit the config button from the SideNav. 2. Click on Backup Tab and then hit the amazon s3 tab. 3. Create a backup config for s3. 4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button. 5. Click on the Edit Configuration button. 6. AWS access credentials should be editable. Do the same for the rest of the configs. Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara * [#7706] Platform: Cherry picked the edit backup config credentials commit. * extra test cases removed * fFormatted the code Co-authored-by: mahenranbhat <mahendra.bhat@hashedin.com>
) * [#7706] Platform: Edit backup config credentials. (#8050) Description: Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups. This change should be implemented for all three storage configs: AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey GCP: Allow editing GCS Credentials [Do not allow editing bucket name] Azure: Allow editing Azure SAS token [Do not allow editing Container URL] Test Plan: 1. Hit the config button from the SideNav. 2. Click on Backup Tab and then hit the amazon s3 tab. 3. Create a backup config for s3. 4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button. 5. Click on the Edit Configuration button. 6. AWS access credentials should be editable. Do the same for the rest of the configs. Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara * [#7706] Platform: Cherry picked the edit backup config credentials commit. * review comment fixes * formatting changes * formatted common.utils Co-authored-by: mahenranbhat <mahendra.bhat@hashedin.com>
) Description: Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups. This change should be implemented for all three storage configs: AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey GCP: Allow editing GCS Credentials [Do not allow editing bucket name] Azure: Allow editing Azure SAS token [Do not allow editing Container URL] Test Plan: 1. Hit the config button from the SideNav. 2. Click on Backup Tab and then hit the amazon s3 tab. 3. Create a backup config for s3. 4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button. 5. Click on the Edit Configuration button. 6. AWS access credentials should be editable. Do the same for the rest of the configs. Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara
Description:
Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups.
This change should be implemented for all three storage configs:
AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey
GCP: Allow editing GCS Credentials [Do not allow editing bucket name]
Azure: Allow editing Azure SAS token [Do not allow editing Container URL]
Test Plan:
amazon s3
tab.Do the same for the rest of the configs.
SBT test
[info] Passed: Total 1304, Failed 0, Errors 0, Passed 1300, Skipped 4 [success] Total time: 1187 s (19:47), completed 12 May, 2021 3:55:27 PM