[8.12] [Cloud Security] Hide temporarily unsupported option from azure manual options (#173988) (#174024)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Cloud Security] Hide temporarily unsupported option from azure
manual options (#173988)](https://github.com/elastic/kibana/pull/173988)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Jordan","email":"51442161+JordanSh@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-12-28T14:50:45Z","message":"[Cloud
Security] Hide temporarily unsupported option from azure manual options
(#173988)","sha":"0d86b40e2dd0b4f70dd344c8078125c515165dd9","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Cloud
Security","v8.12.0","v8.13.0"],"title":"[Cloud Security] Hide
temporarily unsupported option from azure manual
options","number":173988,"url":"https://github.com/elastic/kibana/pull/173988","mergeCommit":{"message":"[Cloud
Security] Hide temporarily unsupported option from azure manual options
(#173988)","sha":"0d86b40e2dd0b4f70dd344c8078125c515165dd9"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/173988","number":173988,"mergeCommit":{"message":"[Cloud
Security] Hide temporarily unsupported option from azure manual options
(#173988)","sha":"0d86b40e2dd0b4f70dd344c8078125c515165dd9"}}]}]
BACKPORT-->

Co-authored-by: Jordan <51442161+JordanSh@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-12-28 10:57:15 -05:00 committed by GitHub
parent c2fda4713e
commit 1ac2f8fec2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 11 deletions

View file

@ -26,15 +26,17 @@ export const getAzureCredentialsFormManualOptions = (): Array<{
value: AzureCredentialsType;
text: string;
}> => {
return (
Object.entries(getAzureCredentialsFormOptions())
.map(([key, value]) => ({
value: key as AzureCredentialsType,
text: value.label,
}))
// TODO: remove 'manual' for stack version 8.13
.filter(({ value }) => value !== 'arm_template' && value !== 'manual')
);
return Object.entries(getAzureCredentialsFormOptions())
.map(([key, value]) => ({
value: key as AzureCredentialsType,
text: value.label,
}))
.filter(
({ value }) =>
value !== 'arm_template' && // we remove this in order to hide it from the selectable options in the manual drop down
value !== 'manual' && // TODO: remove 'manual' for stack version 8.13
value !== 'service_principal_with_client_username_and_password' // this option is temporarily hidden
);
};
export const getInputVarsFields = (input: NewPackagePolicyInput, fields: AzureCredentialsFields) =>

View file

@ -1519,7 +1519,26 @@ describe('<CspPolicyTemplateForm />', () => {
});
});
it(`renders Service principal with Client Username and Password fields`, () => {
it(`should not render Service principal with Client Username and Password option`, () => {
let policy = getMockPolicyAzure();
policy = getPosturePolicy(policy, CLOUDBEAT_AZURE, {
'azure.credentials.type': { value: 'managed_identity' },
});
const { queryByRole } = render(
<WrappedComponent newPolicy={policy} packageInfo={getMockPackageInfoCspmAzure('1.7.0')} />
);
expect(
queryByRole('option', {
name: 'Service principal with Client Username and Password',
selected: false,
})
).not.toBeInTheDocument();
});
// TODO: remove when service_principal_with_client_username_and_password is removed from the code base
it.skip(`renders Service principal with Client Username and Password fields`, () => {
let policy = getMockPolicyAzure();
policy = getPosturePolicy(policy, CLOUDBEAT_AZURE, {
'azure.credentials.type': { value: 'service_principal_with_client_username_and_password' },
@ -1541,7 +1560,8 @@ describe('<CspPolicyTemplateForm />', () => {
expect(getByLabelText('Client Password')).toBeInTheDocument();
});
it(`updates Service principal with Client Username and Password fields`, () => {
// TODO: remove when service_principal_with_client_username_and_password is removed from the code base
it.skip(`updates Service principal with Client Username and Password fields`, () => {
let policy = getMockPolicyAzure();
policy = getPosturePolicy(policy, CLOUDBEAT_AZURE, {
'azure.credentials.type': { value: 'service_principal_with_client_username_and_password' },