|
package security
import "testing"
func TestEncoding(t *testing.T) {
clear := "encoding test"
base64 := encodeBase64([]byte(clear))
decode64 := string(decodeBase64([]byte(base64)))
if decode64 != clear {
t.Error("Encoding does not match")
}
}
func TestEncryption(t *testing.T) {
clear := "encryption test"
passphrase := "password"
encrypted, err := encrypt(clear, passphrase)
if err != nil {
t.Error(err)
}
decrypted, err := decrypt(encrypted, passphrase)
if err != nil {
t.Error(err)
}
if clear != string(decrypted) {
t.Error("Encryption does not match")
}
}
func TestHash(t *testing.T) {
t.Skip("Need a test for hashing")
}
func TestHashCredentials(t *testing.T) {
t.Skip("Need a test for hashing credentials")
}
func TestGeneratePassphrase(t *testing.T) {
username := "bryan"
passphrase := "test"
expected := "o47ZaAu3pd5cK0ZA412Z3rpsi8MDdlUZPkJ9Z51x7QlNUc7S4EGYuT9XIe4HYtzy7vxHah528ibkfd4CjHCSsg=="
generated := GeneratePassphrase(username, passphrase)
if expected != generated {
t.FailNow()
}
}
|