Skip to content

Commit 39eb908

Browse files
Merge pull request #16231 from openshift-cherrypick-robot/cherry-pick-16051-to-release-4.20
[release-4.20] OCPBUGS-81495, OCPBUGS-81496: OLM prompts for GCP Workload Identity parameters during Kiali Operato…
2 parents 3a13a7d + 3e0727c commit 39eb908

2 files changed

Lines changed: 101 additions & 3 deletions

File tree

frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-hub-utils.spec.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ describe('getInfrastructureFeatures', () => {
481481
const result = getInfrastructureFeatures(
482482
{
483483
[OLMAnnotation.InfrastructureFeatures]: '["tokenAuth"]',
484+
[OLMAnnotation.TokenAuthAWS]: 'true',
484485
},
485486
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
486487
);
@@ -493,6 +494,7 @@ describe('getInfrastructureFeatures', () => {
493494
const result = getInfrastructureFeatures(
494495
{
495496
[OLMAnnotation.InfrastructureFeatures]: '["TokenAuth"]',
497+
[OLMAnnotation.TokenAuthAWS]: 'true',
496498
},
497499
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
498500
);
@@ -505,6 +507,7 @@ describe('getInfrastructureFeatures', () => {
505507
const result = getInfrastructureFeatures(
506508
{
507509
[OLMAnnotation.InfrastructureFeatures]: '["tokenAuth"]',
510+
[OLMAnnotation.TokenAuthAzure]: 'true',
508511
},
509512
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
510513
);
@@ -517,6 +520,7 @@ describe('getInfrastructureFeatures', () => {
517520
const result = getInfrastructureFeatures(
518521
{
519522
[OLMAnnotation.InfrastructureFeatures]: '["TokenAuth"]',
523+
[OLMAnnotation.TokenAuthAzure]: 'true',
520524
},
521525
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
522526
);
@@ -541,6 +545,7 @@ describe('getInfrastructureFeatures', () => {
541545
const result = getInfrastructureFeatures(
542546
{
543547
[OLMAnnotation.InfrastructureFeatures]: '["tokenAuthGCP"]',
548+
[OLMAnnotation.TokenAuthGCP]: 'true',
544549
},
545550
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
546551
);
@@ -553,6 +558,7 @@ describe('getInfrastructureFeatures', () => {
553558
const result = getInfrastructureFeatures(
554559
{
555560
[OLMAnnotation.InfrastructureFeatures]: '["TokenAuthGCP"]',
561+
[OLMAnnotation.TokenAuthGCP]: 'true',
556562
},
557563
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
558564
);
@@ -570,6 +576,96 @@ describe('getInfrastructureFeatures', () => {
570576
);
571577
expect(result).toEqual([]);
572578
});
579+
it(`excludes token auth GCP feature when annotation is explicitly set to false`, () => {
580+
const clusterIsAWSSTS = false;
581+
const clusterIsAzureWIF = false;
582+
const clusterIsGCPWIF = true;
583+
const result = getInfrastructureFeatures(
584+
{
585+
[OLMAnnotation.TokenAuthGCP]: 'false',
586+
},
587+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
588+
);
589+
expect(result).toEqual([]);
590+
});
591+
it(`excludes legacy token auth GCP feature when annotation is explicitly set to false on GCP WIF cluster`, () => {
592+
const clusterIsAWSSTS = false;
593+
const clusterIsAzureWIF = false;
594+
const clusterIsGCPWIF = true;
595+
const result = getInfrastructureFeatures(
596+
{
597+
[OLMAnnotation.InfrastructureFeatures]: '["TokenAuthGCP"]',
598+
[OLMAnnotation.TokenAuthGCP]: 'false',
599+
},
600+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
601+
);
602+
expect(result).toEqual([]);
603+
});
604+
it(`excludes token auth AWS feature when annotation is not present on AWS STS cluster`, () => {
605+
const clusterIsAWSSTS = true;
606+
const clusterIsAzureWIF = false;
607+
const clusterIsGCPWIF = false;
608+
const result = getInfrastructureFeatures(
609+
{}, // No TokenAuthAWS annotation
610+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
611+
);
612+
expect(result).toEqual([]);
613+
expect(result).not.toContain(InfrastructureFeature.TokenAuth);
614+
});
615+
it(`excludes token auth Azure feature when annotation is not present on Azure WIF cluster`, () => {
616+
const clusterIsAWSSTS = false;
617+
const clusterIsAzureWIF = true;
618+
const clusterIsGCPWIF = false;
619+
const result = getInfrastructureFeatures(
620+
{}, // No TokenAuthAzure annotation
621+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
622+
);
623+
expect(result).toEqual([]);
624+
expect(result).not.toContain(InfrastructureFeature.TokenAuth);
625+
});
626+
it(`excludes token auth GCP feature when annotation is not present on GCP WIF cluster`, () => {
627+
const clusterIsAWSSTS = false;
628+
const clusterIsAzureWIF = false;
629+
const clusterIsGCPWIF = true;
630+
const result = getInfrastructureFeatures(
631+
{}, // No TokenAuthGCP annotation
632+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
633+
);
634+
expect(result).toEqual([]);
635+
expect(result).not.toContain(InfrastructureFeature.TokenAuthGCP);
636+
});
637+
it(`requires explicit true annotation for all token auth providers (opt-in behavior)`, () => {
638+
const clusterIsAWSSTS = true;
639+
const clusterIsAzureWIF = true;
640+
const clusterIsGCPWIF = true;
641+
// Test with annotations missing
642+
const resultMissing = getInfrastructureFeatures(
643+
{},
644+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
645+
);
646+
expect(resultMissing).toEqual([]);
647+
// Test with annotations set to 'false'
648+
const resultFalse = getInfrastructureFeatures(
649+
{
650+
[OLMAnnotation.TokenAuthAWS]: 'false',
651+
[OLMAnnotation.TokenAuthAzure]: 'false',
652+
[OLMAnnotation.TokenAuthGCP]: 'false',
653+
},
654+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
655+
);
656+
expect(resultFalse).toEqual([]);
657+
// Test with annotations set to 'true' - only this should include features
658+
const resultTrue = getInfrastructureFeatures(
659+
{
660+
[OLMAnnotation.TokenAuthAWS]: 'true',
661+
[OLMAnnotation.TokenAuthAzure]: 'true',
662+
[OLMAnnotation.TokenAuthGCP]: 'true',
663+
},
664+
{ clusterIsAWSSTS, clusterIsAzureWIF, clusterIsGCPWIF },
665+
);
666+
expect(resultTrue).toContain(InfrastructureFeature.TokenAuth);
667+
expect(resultTrue).toContain(InfrastructureFeature.TokenAuthGCP);
668+
});
573669
it(`includes features defined by latest annotation format`, () => {
574670
const clusterIsAWSSTS = true;
575671
const clusterIsAzureWIF = true;

frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-hub-utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,11 @@ export const getInfrastructureFeatures: AnnotationParser<
218218
onError,
219219
});
220220
const azureTokenAuthIsSupported =
221-
clusterIsAzureWIF && annotations[OLMAnnotation.TokenAuthAzure] !== 'false';
221+
clusterIsAzureWIF && annotations[OLMAnnotation.TokenAuthAzure] === 'true';
222222
const awsTokenAuthIsSupported =
223-
clusterIsAWSSTS && annotations[OLMAnnotation.TokenAuthAWS] !== 'false';
223+
clusterIsAWSSTS && annotations[OLMAnnotation.TokenAuthAWS] === 'true';
224+
const gcpTokenAuthIsSupported =
225+
clusterIsGCPWIF && annotations[OLMAnnotation.TokenAuthGCP] === 'true';
224226
return [...parsedInfrastructureFeatures, ...Object.keys(annotations ?? {})].reduce(
225227
(supportedFeatures, key) => {
226228
const feature = infrastructureFeatureMap[key];
@@ -245,7 +247,7 @@ export const getInfrastructureFeatures: AnnotationParser<
245247
return tokenAuthIsSupported ? includeFeature() : excludeFeature();
246248
};
247249
const resolveTokenAuthGCPFeature = () => {
248-
return clusterIsGCPWIF ? includeFeature() : excludeFeature();
250+
return gcpTokenAuthIsSupported ? includeFeature() : excludeFeature();
249251
};
250252

251253
switch (feature) {

0 commit comments

Comments
 (0)