mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
35 lines
607 B
Go
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("")
|
||
|
}
|
||
|
}
|