From 34954ce83a00a7490962ff12b6acc4d54f1c7e30 Mon Sep 17 00:00:00 2001 From: Sachin Divekar Date: Tue, 24 Feb 2026 19:58:54 +0530 Subject: [PATCH] Fix test failures in reqmapper and simplekeymanager plugins - reqmapper/cmd: Add missing mappingsFile to TestProviderNewSuccess config - simplekeymanager/cmd: Fix wantErr for partial config (keyId-only) case - simplekeymanager/cmd: Use valid base64 key values in TestConfigMapping - simplekeymanager: Remove incorrect SubscriberID assertion from TestGenerateKeyset (GenerateKeyset generates raw keys, subscriber identity is assigned separately) --- .../implementation/reqmapper/cmd/plugin_test.go | 3 ++- .../simplekeymanager/cmd/plugin_test.go | 11 +++++------ .../simplekeymanager/simplekeymanager_test.go | 4 ---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/pkg/plugin/implementation/reqmapper/cmd/plugin_test.go b/pkg/plugin/implementation/reqmapper/cmd/plugin_test.go index d6d1bba..c7ef84d 100644 --- a/pkg/plugin/implementation/reqmapper/cmd/plugin_test.go +++ b/pkg/plugin/implementation/reqmapper/cmd/plugin_test.go @@ -11,7 +11,8 @@ import ( func TestProviderNewSuccess(t *testing.T) { p := provider{} - middleware, err := p.New(context.Background(), map[string]string{"role": "bap"}) + mappingFile := "../testdata/mappings.yaml" + middleware, err := p.New(context.Background(), map[string]string{"role": "bap", "mappingsFile": mappingFile}) if err != nil { t.Fatalf("provider.New returned unexpected error: %v", err) } diff --git a/pkg/plugin/implementation/simplekeymanager/cmd/plugin_test.go b/pkg/plugin/implementation/simplekeymanager/cmd/plugin_test.go index 3ca199b..1845675 100644 --- a/pkg/plugin/implementation/simplekeymanager/cmd/plugin_test.go +++ b/pkg/plugin/implementation/simplekeymanager/cmd/plugin_test.go @@ -76,7 +76,7 @@ func TestSimpleKeyManagerProvider_New(t *testing.T) { config: map[string]string{ "keyId": "test-key", }, - wantErr: false, + wantErr: true, }, } @@ -145,14 +145,13 @@ func TestConfigMapping(t *testing.T) { cache := &mockCache{} registry := &mockRegistry{} - // Test config mapping configMap := map[string]string{ "networkParticipant": "mapped-np", "keyId": "mapped-key-id", - "signingPrivateKey": "mapped-signing-private", - "signingPublicKey": "mapped-signing-public", - "encrPrivateKey": "mapped-encr-private", - "encrPublicKey": "mapped-encr-public", + "signingPrivateKey": "dGVzdC1zaWduaW5nLXByaXZhdGU=", + "signingPublicKey": "dGVzdC1zaWduaW5nLXB1YmxpYw==", + "encrPrivateKey": "dGVzdC1lbmNyLXByaXZhdGU=", + "encrPublicKey": "dGVzdC1lbmNyLXB1YmxpYw==", } // We can't directly test the config mapping without exposing internals, diff --git a/pkg/plugin/implementation/simplekeymanager/simplekeymanager_test.go b/pkg/plugin/implementation/simplekeymanager/simplekeymanager_test.go index 8d07c48..16bde9b 100644 --- a/pkg/plugin/implementation/simplekeymanager/simplekeymanager_test.go +++ b/pkg/plugin/implementation/simplekeymanager/simplekeymanager_test.go @@ -181,10 +181,6 @@ func TestGenerateKeyset(t *testing.T) { return } - // Check that all fields are populated - if keyset.SubscriberID == "" { - t.Error("GenerateKeyset() SubscriberID is empty") - } if keyset.UniqueKeyID == "" { t.Error("GenerateKeyset() UniqueKeyID is empty") }