Semaphore/db/AccessKey_test.go
2021-09-01 19:38:28 +05:00

35 lines
607 B
Go

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("")
}
}