-
Notifications
You must be signed in to change notification settings - Fork 13
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
1 parent
c64a423
commit 12f823a
Showing
4 changed files
with
76 additions
and
70 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
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,71 @@ | ||
package oauth | ||
|
||
import "testing" | ||
|
||
func TestGetKey(t *testing.T) { | ||
cases := []struct { | ||
description string | ||
kr *keyReader | ||
}{ | ||
{ | ||
"no password", | ||
&keyReader{ | ||
privKey: "../../apic/auth/testdata/private_key.pem", | ||
}, | ||
}, | ||
{ | ||
"with empty password file", | ||
&keyReader{ | ||
privKey: "../../apic/auth/testdata/private_key.pem", | ||
password: "../../apic/auth/testdata/password_empty", | ||
}, | ||
}, | ||
{ | ||
"with password", | ||
&keyReader{ | ||
privKey: "../../apic/auth/testdata/private_key_with_pwd.pem", | ||
password: "../../apic/auth/testdata/password", | ||
}, | ||
}, | ||
} | ||
|
||
for _, testCase := range cases { | ||
if _, err := testCase.kr.GetPrivateKey(); err != nil { | ||
t.Errorf("testcase: %s: failed to read rsa key %s", testCase.description, err) | ||
} | ||
} | ||
} | ||
|
||
func TestGetPublicKey(t *testing.T) { | ||
cases := []struct { | ||
description string | ||
kr *keyReader | ||
}{ | ||
{ | ||
"with public key", | ||
&keyReader{ | ||
publicKey: "../../apic/auth/testdata/public_key", | ||
}, | ||
}, | ||
{ | ||
"with private and public key", | ||
&keyReader{ | ||
privKey: "../../apic/auth/testdata/private_key.pem", | ||
publicKey: "../../apic/auth/testdata/public_key", | ||
}, | ||
}, | ||
{ | ||
"with private, public key, and password", | ||
&keyReader{ | ||
privKey: "../../apic/auth/testdata/private_key_with_pwd.pem", | ||
password: "../../apic/auth/testdata/password", | ||
publicKey: "../../apic/auth/testdata/public_key", | ||
}, | ||
}, | ||
} | ||
for _, testCase := range cases { | ||
if _, err := testCase.kr.GetPublicKey(); err != nil { | ||
t.Errorf("testcase: %s: failed to read public key %s", testCase.description, err) | ||
} | ||
} | ||
} |
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