This repository has been archived by the owner on Jan 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the parsing of the Google RSA key
If the key comes from the config file it should be fine as is. Otherwise we replace spaces with newlines and add back the BEGIN and END RSA blocks. This adds a unit test for this.
- Loading branch information
1 parent
79ce36c
commit 3a82aa7
Showing
2 changed files
with
42 additions
and
7 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,24 @@ | ||
package awsconsoleauth | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestFormatRsaKey(t *testing.T) { | ||
expected := `-----BEGIN RSA PRIVATE KEY----- | ||
FAKEFAKEABCDEF12345678FAKEFAKEABCDEF12345678FAKEFAKEABCDEF123456 | ||
FAKEFAKEABCDEF12345678FAKEFAKEABCDEF12345678FAKEFAKEABCDEF123456 | ||
FAKEFAKEABCDEF12345678FAKEFAKEABCDEF12345678FAKEFAKEABCDEF123456 | ||
-----END RSA PRIVATE KEY-----` | ||
|
||
actual := formatRsaKey(expected) | ||
if actual != expected { | ||
t.Errorf("Normal: expected %q, got %q", expected, actual) | ||
} | ||
|
||
compact := "FAKEFAKEABCDEF12345678FAKEFAKEABCDEF12345678FAKEFAKEABCDEF123456 FAKEFAKEABCDEF12345678FAKEFAKEABCDEF12345678FAKEFAKEABCDEF123456 FAKEFAKEABCDEF12345678FAKEFAKEABCDEF12345678FAKEFAKEABCDEF123456" | ||
actual = formatRsaKey(compact) | ||
if actual != expected { | ||
t.Errorf("Compact: expected %q, got %q", expected, actual) | ||
} | ||
} |