mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-24 05:37:09 +02:00
e3935ca088
* rotate Vault secret on GH Actions * test alternative sodium package * try doing it without libsodium * disable validity check for testing purposes * basic unit test * re-enable secret validity check * tidy * tidy parameters * forgot to update param names in code * apply review feedback * improve error logging * update step metadata * apply metadata suggestion from review Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com> * align githubToken param * Fix secretStore * Add alias for githubToken * Move logic to separate file --------- Co-authored-by: I557621 <jordi.van.liempt@sap.com> Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com> Co-authored-by: Vyacheslav Starostin <vyacheslav.starostin@sap.com>
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)
|
|
})
|
|
}
|