-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cloud-api-adaptor: add unit tests to securecomms
Add unit tests and improve test facilities Signed-off-by: David Hadas <david.hadas@gmail.com>
- Loading branch information
1 parent
4489206
commit 0862ea0
Showing
19 changed files
with
698 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/cloud-api-adaptor/pkg/securecomms/kubemgr/kubemgr_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package kubemgr | ||
|
||
import ( | ||
"slices" | ||
"testing" | ||
) | ||
|
||
func TestSecrets(t *testing.T) { | ||
InitKubeMgrMock() | ||
|
||
privateKey1, publicKey1, err1 := KubeMgr.CreateSecret("XYZ") | ||
if err1 != nil { | ||
t.Error(err1) | ||
} | ||
|
||
privateKey2, publicKey2, err2 := KubeMgr.ReadSecret("XYZ") | ||
if err1 != nil { | ||
t.Error(err2) | ||
} | ||
_, _, err3 := KubeMgr.ReadSecret("ABC") | ||
if err3 == nil { | ||
t.Error("Expected error") | ||
} | ||
|
||
KubeMgr.DeleteSecret("XYZ") | ||
KubeMgr.DeleteSecret("ABC") | ||
|
||
if !slices.Equal(publicKey1, publicKey2) { | ||
t.Error("publicKey not equal") | ||
} | ||
if !slices.Equal(privateKey1, privateKey2) { | ||
t.Error("privateKey not equal") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.