going somewhere
This commit is contained in:
1 parent
6b3c99664c
commit
209af0d820
16 files changed
+549
-131
No files matched your search
@@ -1 +1,63 @@
|
||||
package asymetric
|
||||
package asymetric
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"testing"
|
||||
|
||||
"github.com/didiercrunch/filou/contract"
|
||||
)
|
||||
|
||||
func TestGetSignerEmptyContract(t *testing.T) {
|
||||
c := new(contract.AcceptedContract)
|
||||
if _, err := GetSigner(c); err == nil {
|
||||
t.Error("exceptec an error here")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSignerBadName(t *testing.T) {
|
||||
c := new(contract.AcceptedContract)
|
||||
c.SignatureScheme = "bigtits.com"
|
||||
if _, err := GetSigner(c); err == nil {
|
||||
t.Error("exceptec an error here")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSigner(t *testing.T) {
|
||||
c := new(contract.AcceptedContract)
|
||||
priv, pub := generateKeyPair()
|
||||
|
||||
c.Hash = "sha256"
|
||||
c.SignatureScheme = "rsa_pss"
|
||||
c.RsaPublicKey = pub
|
||||
|
||||
c.RsaPrivateKey = func() (*rsa.PrivateKey, error) {
|
||||
return priv, nil
|
||||
}
|
||||
if _, err := GetSigner(c); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPublicKeyEncryptor(t *testing.T) {
|
||||
c := new(contract.AcceptedContract)
|
||||
priv, pub := generateKeyPair()
|
||||
|
||||
c.Hash = "sha256"
|
||||
c.AsynchronousEncryptionScheme = "rsa_oaep"
|
||||
c.RsaPublicKey = pub
|
||||
|
||||
c.RsaPrivateKey = func() (*rsa.PrivateKey, error) {
|
||||
return priv, nil
|
||||
}
|
||||
if _, err := GetPublicKeyEncryptor(c); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPublicKeyEncryptorBadName(t *testing.T) {
|
||||
c := new(contract.AcceptedContract)
|
||||
c.AsynchronousEncryptionScheme = "bigtits.com"
|
||||
if _, err := GetPublicKeyEncryptor(c); err == nil {
|
||||
t.Error("exceptec an error here")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user