generated from replicatedhq/krew-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package plugin | ||
|
||
import ( | ||
// Necessary imports | ||
"crypto/elliptic" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestRandSeq(t *testing.T) { | ||
length := 10 | ||
seq := randSeq(length) | ||
if len(seq) != length { | ||
t.Errorf("Expected length %d, got %d", length, len(seq)) | ||
} | ||
allowedChars := "abcdefghijklmnopqrstuvwxyz0123456789" | ||
for _, char := range seq { | ||
if !strings.ContainsRune(allowedChars, char) { | ||
t.Errorf("Invalid character %c in sequence", char) | ||
} | ||
} | ||
} | ||
|
||
func TestGenerateKeyPair(t *testing.T) { | ||
privateKey, publicKey, err := GenerateKeyPair(elliptic.P256()) | ||
if err != nil { | ||
t.Fatalf("GenerateKeyPair returned an error: %v", err) | ||
} | ||
if privateKey == "" || publicKey == "" { | ||
t.Error("GenerateKeyPair returned empty keys") | ||
} | ||
// Additional checks can be added to validate the key formats | ||
} |