1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/pkg/piperutils/credentials_test.go
Christopher Fenner f78777f784
feat(npm): allow to publish artifact to registry (#2871)
* add new paraeters

* update generated sources

* run npm publish

* add repositoryUrl parameter

* handle registry credentials

* rename parameter

* handle base64encoding

* remove vault reference

* make username secret

* add publish method

* use publish method

* use dedicated registry

* use dry run

* fix

* prepend path

* fix workdir

* move code to npm package

* do changes

* update dependencies

* correct property init

* remomve dry-run

* regenerate

* add mock

* add logging

* add debug log

* dry-run

* remove try run

* remove append

* add debug outut

* change

* add debug output

* changes

* cleanup

* use different auth property

* add credential utils

* add debug log outputs

* remove auth handling & reuse writeFile

* rename

* fix debug output

* remove comments

* update comment

* rename function

* update docs

* update generated files

* handle npm ignore

* remove commented code

* add debug output
2021-07-15 14:46:04 +02:00

47 lines
952 B
Go

package piperutils
import (
"testing"
)
func TestEncodeUsernamePassword(t *testing.T) {
type args struct {
username string
password string
}
tests := []struct {
name string
args args
want string
}{
{args: args{username: "anything", password: "something"}, want: "YW55dGhpbmc6c29tZXRoaW5n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := EncodeUsernamePassword(tt.args.username, tt.args.password); got != tt.want {
t.Errorf("EncodeUsernamePassword() = %v, want %v", got, tt.want)
}
})
}
}
func TestEncodeToken(t *testing.T) {
type args struct {
token string
}
tests := []struct {
name string
args args
want string
}{
{args: args{token: "anything"}, want: "YW55dGhpbmc="},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := EncodeString(tt.args.token); got != tt.want {
t.Errorf("EncodeToken() = %v, want %v", got, tt.want)
}
})
}
}