Skip to content

Commit c32f719

Browse files
authored
test: fix githubapp expectation in proxy e2e test (#1801)
The fake githubapp Secret actually breaks the expectation for the RootSyncStalledError, since it makes the RootSync spec valid. This creates a race condition where the stalled error must be detected before the reconciler-manager can reconcile the contrived Secret. The fake secret is unnecessary for the assertion and is removed.
1 parent 1c42b7c commit c32f719

File tree

2 files changed

+0
-55
lines changed

2 files changed

+0
-55
lines changed

e2e/nomostest/config_sync.go

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,57 +1516,3 @@ func SetupFakeSSHCreds(nt *NT, rsKind string, rsRef types.NamespacedName, auth c
15161516
})
15171517
return nil
15181518
}
1519-
1520-
// SetupFakeGithubAppCreds sets up the RSync Secret when needed.
1521-
func SetupFakeGithubAppCreds(nt *NT, rsKind string, rsRef types.NamespacedName, auth configsync.AuthType, secretName string) error {
1522-
if controllers.SkipForAuth(auth) {
1523-
nt.T.Logf("The auth type %s doesn't need a Secret", auth)
1524-
return nil
1525-
}
1526-
1527-
gitSecretGithubAppPrivateKey := "github-app-private-key"
1528-
gitSecretGithubAppInstallationID := "github-app-installation-id"
1529-
gitSecretGithubAppApplicationID := reconcilermanager.GitSecretGithubAppApplicationID
1530-
1531-
secret := k8sobjects.SecretObject(secretName, core.Namespace(rsRef.Namespace))
1532-
err := nt.KubeClient.Get(secret.Name, secret.Namespace, secret)
1533-
if err == nil {
1534-
// The Secret is already created by the test scaffolding.
1535-
// Add or update the GitHub App keys.
1536-
secret.Data[gitSecretGithubAppApplicationID] = []byte(gitSecretGithubAppApplicationID)
1537-
secret.Data[gitSecretGithubAppInstallationID] = []byte(gitSecretGithubAppInstallationID)
1538-
secret.Data[gitSecretGithubAppPrivateKey] = []byte(gitSecretGithubAppPrivateKey)
1539-
if err = nt.KubeClient.Update(secret); err != nil {
1540-
return err
1541-
}
1542-
return nil
1543-
}
1544-
if !apierrors.IsNotFound(err) {
1545-
return err
1546-
}
1547-
1548-
nt.T.Logf("The %s/%s Secret doesn't exist with auth %q, so creating a fake one", rsRef.Namespace, secretName, auth)
1549-
if rsKind == kinds.RootSyncV1Beta1().Kind {
1550-
if err := nt.Watcher.WatchForRootSyncStalledError(rsRef.Name, "Validation", validate.MissingSecret(secretName).Error()); err != nil {
1551-
return err
1552-
}
1553-
} else {
1554-
if err := nt.Watcher.WatchForRepoSyncStalledError(rsRef.Namespace, rsRef.Name, "Validation", validate.MissingSecret(secretName).Error()); err != nil {
1555-
return err
1556-
}
1557-
}
1558-
1559-
secret.Data[gitSecretGithubAppApplicationID] = []byte(gitSecretGithubAppApplicationID)
1560-
secret.Data[gitSecretGithubAppInstallationID] = []byte(gitSecretGithubAppInstallationID)
1561-
secret.Data[gitSecretGithubAppPrivateKey] = []byte(gitSecretGithubAppPrivateKey)
1562-
1563-
if err = nt.KubeClient.Create(secret); err != nil {
1564-
return err
1565-
}
1566-
nt.T.Cleanup(func() {
1567-
if err = nt.KubeClient.Delete(secret); err != nil {
1568-
nt.T.Error(err)
1569-
}
1570-
})
1571-
return nil
1572-
}

e2e/testcases/proxy_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func TestSyncingThroughAProxy(t *testing.T) {
6464
nt.T.Log("Set auth type to githubapp")
6565
nt.MustMergePatch(rs, `{"spec": {"git": {"auth": "githubapp"}}}`)
6666
nt.T.Log("Verify the secretRef error")
67-
nt.Must(nomostest.SetupFakeGithubAppCreds(nt, rootSyncID.Kind, rootSyncID.ObjectKey, configsync.AuthGithubApp, controllers.GitCredentialVolume))
6867
nt.Must(nt.Watcher.WatchForRootSyncStalledError(rs.Name, "Validation",
6968
validate.MissingKeyInAuthSecret(configsync.AuthGithubApp, "github-app-private-key", "git-creds").Error()))
7069
nt.T.Log("Set auth type to none")

0 commit comments

Comments
 (0)