Semaphore/db/AccessKey_test.go

35 lines
607 B
Go
Raw Normal View History

2021-09-01 16:38:28 +02:00
package db
import (
"encoding/base64"
"github.com/ansible-semaphore/semaphore/util"
"testing"
)
func TestGetSecret(t *testing.T) {
secret := base64.StdEncoding.EncodeToString([]byte(`{
"passphrase": "123456",
"private_key": "qerphqeruqoweurqwerqqeuiqwpavqr"
}`))
util.Config = &util.ConfigType{}
accessKey := AccessKey{
Secret: &secret,
Type: AccessKeySSH,
}
err := accessKey.DeserializeSecret()
if err != nil {
t.Error(err)
}
if accessKey.SshKey.Passphrase != "123456" {
t.Errorf("")
}
if accessKey.SshKey.PrivateKey != "qerphqeruqoweurqwerqqeuiqwpavqr" {
t.Errorf("")
}
}