mirror of
https://github.com/imjasonh/git-k8s
synced 2026-07-13 08:57:00 +00:00
- Extract triplicated splitKey into shared pkg/reconciler/internal package using strings.Cut and removing the unnecessary error return - Fix resolver merge bug: attemptMerge was using treeA.Hash as the merge commit tree, silently dropping all of branch B's changes. Now builds a proper merged tree that applies B's non-conflicting changes onto A's tree - Replace hand-rolled nestedFieldNoCopy/unstructuredNestedStringMap with k8s.io/apimachinery's unstructured.NestedStringMap stdlib equivalent - Hoist branch listing out of per-refspec loop in updateBranches to avoid redundant API calls - Add not-found handling in all three reconcilers so deleted resources don't cause infinite requeue loops - Fix client.Get() to use checked type assertion with a clear panic message instead of an opaque nil-pointer dereference - Remove dead code: unused addDefaultingFuncs wrapper, unused context injection in push controller setup https://claude.ai/code/session_01634JRpHEoM9FzuBjZ7qHcY
44 lines
1,020 B
Go
44 lines
1,020 B
Go
package push
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"testing"
|
|
)
|
|
|
|
func TestBase64Decoding(t *testing.T) {
|
|
// Verify that values typically stored in Kubernetes secrets
|
|
// (base64-encoded via dynamic client) decode correctly.
|
|
tests := []struct {
|
|
name string
|
|
encoded string
|
|
wantText string
|
|
}{
|
|
{
|
|
name: "simple username",
|
|
encoded: base64.StdEncoding.EncodeToString([]byte("admin")),
|
|
wantText: "admin",
|
|
},
|
|
{
|
|
name: "password with special chars",
|
|
encoded: base64.StdEncoding.EncodeToString([]byte("p@ss!w0rd#123")),
|
|
wantText: "p@ss!w0rd#123",
|
|
},
|
|
{
|
|
name: "empty string",
|
|
encoded: base64.StdEncoding.EncodeToString([]byte("")),
|
|
wantText: "",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
decoded, err := base64.StdEncoding.DecodeString(tt.encoded)
|
|
if err != nil {
|
|
t.Fatalf("DecodeString() error = %v", err)
|
|
}
|
|
if string(decoded) != tt.wantText {
|
|
t.Errorf("decoded = %q, want %q", string(decoded), tt.wantText)
|
|
}
|
|
})
|
|
}
|
|
}
|