|
|
@@ -14,8 +14,11 @@ limitations under the License.
|
|
|
package gitlab
|
|
|
|
|
|
import (
|
|
|
+ "context"
|
|
|
"fmt"
|
|
|
"testing"
|
|
|
+
|
|
|
+ "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
|
|
|
)
|
|
|
|
|
|
func TestCreateGitlabClient(t *testing.T) {
|
|
|
@@ -23,6 +26,42 @@ func TestCreateGitlabClient(t *testing.T) {
|
|
|
gitlab := NewGitlabProvider()
|
|
|
gitlab.NewGitlabClient(credentials, GITLAB_PROJECT_ID)
|
|
|
|
|
|
- user, _, _ := gitlab.client.Users.CurrentUser()
|
|
|
- fmt.Printf("Created client for username: %v", user)
|
|
|
+ // user, _, _ := gitlab.client.Users.CurrentUser()
|
|
|
+ // fmt.Printf("Created client for username: %v", user)
|
|
|
+}
|
|
|
+
|
|
|
+func TestGetSecret(t *testing.T) {
|
|
|
+ ctx := context.Background()
|
|
|
+
|
|
|
+ ref := v1alpha1.ExternalSecretDataRemoteRef{Key: "mySecretBanana"}
|
|
|
+
|
|
|
+ credentials := GitlabCredentials{Token: GITLAB_TOKEN}
|
|
|
+ gitlab := NewGitlabProvider()
|
|
|
+ gitlab.NewGitlabClient(credentials, GITLAB_PROJECT_ID)
|
|
|
+
|
|
|
+ secretData, err := gitlab.GetSecret(ctx, ref)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("that's an error, Charlie. %v", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Printf("Got secret data %v", string(secretData))
|
|
|
+}
|
|
|
+
|
|
|
+func TestGetSecretMap(t *testing.T) {
|
|
|
+ ctx := context.Background()
|
|
|
+
|
|
|
+ ref := v1alpha1.ExternalSecretDataRemoteRef{Key: "myJsonSecret"}
|
|
|
+
|
|
|
+ credentials := GitlabCredentials{Token: GITLAB_TOKEN}
|
|
|
+ gitlab := NewGitlabProvider()
|
|
|
+ gitlab.NewGitlabClient(credentials, GITLAB_PROJECT_ID)
|
|
|
+
|
|
|
+ secretData, err := gitlab.GetSecretMap(ctx, ref)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Errorf("that's an error, Charlie. %w", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Printf("Got secret map: %v", secretData)
|
|
|
}
|