Skip to content

Commit 04f81cb

Browse files
committed
remove e2e add unit
Signed-off-by: rashmi_kh <[email protected]>
1 parent 40bd6ba commit 04f81cb

File tree

2 files changed

+3
-66
lines changed

2 files changed

+3
-66
lines changed

internal/authentication/tokengetter_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ func TestTokenGetterGet(t *testing.T) {
7272
"test-namespace-3", "test-token-3", "failed to get token"},
7373
{"Testing error when getting token from fake client", "test-service-account-4",
7474
"test-namespace-4", "error when fetching token", "error when fetching token"},
75+
{"Testing service account not found", "missing-sa",
76+
"test-namespace-5", "", "service account \"missing-sa\" not found in namespace \"test-namespace-5\": unable to authenticate with the Kubernetes cluster."},
7577
}
7678

7779
for _, tc := range tests {
7880
got, err := tg.Get(context.Background(), types.NamespacedName{Namespace: tc.namespace, Name: tc.serviceAccountName})
7981
if err != nil {
8082
t.Logf("%s: expected: %v, got: %v", tc.testName, tc.want, err)
81-
assert.EqualError(t, err, tc.errorMsg)
83+
assert.EqualError(t, err, tc.errorMsg, "Error message should match expected output")
8284
} else {
8385
t.Logf("%s: expected: %v, got: %v", tc.testName, tc.want, got)
8486
assert.Equal(t, tc.want, got, tc.errorMsg)

test/e2e/cluster_extension_install_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -360,71 +360,6 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
360360
}
361361
}
362362

363-
func TestClusterExtensionInstallFailsWithoutServiceAccount(t *testing.T) {
364-
t.Log("When a cluster extension is installed from a catalog")
365-
t.Log("And the ServiceAccount does not exist")
366-
367-
// Step 1: Setup test environment without creating an SA
368-
clusterExtensionName := fmt.Sprintf("clusterextension-%s", rand.String(8))
369-
370-
ns, err := createNamespace(context.Background(), clusterExtensionName)
371-
require.NoError(t, err)
372-
373-
extensionCatalog, err := createTestCatalog(context.Background(), testCatalogName, os.Getenv(testCatalogRefEnvVar))
374-
require.NoError(t, err)
375-
376-
// Important: We do NOT create a ServiceAccount here
377-
defer testCleanup(t, extensionCatalog, nil, nil, ns)
378-
defer utils.CollectTestArtifacts(t, artifactName, c, cfg)
379-
380-
// Step 2: Define the ClusterExtension with a non-existent SA
381-
clusterExtension := &ocv1.ClusterExtension{
382-
ObjectMeta: metav1.ObjectMeta{
383-
Name: clusterExtensionName,
384-
},
385-
Spec: ocv1.ClusterExtensionSpec{
386-
Source: ocv1.SourceConfig{
387-
SourceType: "Catalog",
388-
Catalog: &ocv1.CatalogSource{
389-
PackageName: "test",
390-
Selector: &metav1.LabelSelector{
391-
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
392-
},
393-
},
394-
},
395-
Namespace: ns.Name,
396-
ServiceAccount: ocv1.ServiceAccountReference{
397-
Name: "non-existent-sa", // This SA does NOT exist
398-
},
399-
},
400-
}
401-
402-
t.Log("By creating the ClusterExtension resource without a ServiceAccount")
403-
require.NoError(t, c.Create(context.Background(), clusterExtension))
404-
405-
// Step 3: Validate failure due to missing ServiceAccount
406-
t.Log("By eventually reporting an installation failure due to missing ServiceAccount")
407-
require.EventuallyWithT(t, func(ct *assert.CollectT) {
408-
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
409-
410-
// Validate that Progressing reports failure
411-
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
412-
if assert.NotNil(ct, cond) {
413-
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
414-
assert.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
415-
assert.Contains(ct, cond.Message, "installation cannot proceed due to missing ServiceAccount")
416-
}
417-
418-
// Validate that Installed condition is false
419-
installCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled)
420-
if assert.NotNil(ct, installCond) {
421-
assert.Equal(ct, metav1.ConditionUnknown, installCond.Status)
422-
assert.Equal(ct, ocv1.ReasonFailed, installCond.Reason)
423-
assert.Contains(ct, installCond.Message, "service account")
424-
}
425-
}, pollDuration, pollInterval)
426-
}
427-
428363
func TestClusterExtensionInstallRegistryDynamic(t *testing.T) {
429364
// NOTE: Like 'TestClusterExtensionInstallRegistry', this test also requires extra configuration in /etc/containers/registries.conf
430365
packageName := "dynamic"

0 commit comments

Comments
 (0)