mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-22 05:33:10 +02:00
31 lines
698 B
Go
31 lines
698 B
Go
|
package github
|
||
|
|
||
|
import (
|
||
|
"encoding/base64"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/google/go-github/v45/github"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestRunGithubCreateEncryptedSecret(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
t.Run("Success", func(t *testing.T) {
|
||
|
mockKeyID := "1"
|
||
|
mockB64Key := base64.StdEncoding.EncodeToString([]byte("testPublicKey"))
|
||
|
mockPubKey := github.PublicKey{KeyID: &mockKeyID, Key: &mockB64Key}
|
||
|
|
||
|
mockName := "testSecret"
|
||
|
mockValue := "testValue"
|
||
|
|
||
|
// test
|
||
|
githubSecret, err := CreateEncryptedSecret(mockName, mockValue, &mockPubKey)
|
||
|
|
||
|
// assert
|
||
|
assert.NoError(t, err)
|
||
|
assert.Equal(t, mockName, githubSecret.Name)
|
||
|
assert.Equal(t, mockKeyID, githubSecret.KeyID)
|
||
|
})
|
||
|
}
|