Add support for GCP Secret Manager
This commit is contained in:
35
google_test.go
Normal file
35
google_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package secret
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGCPSecretManager(t *testing.T) {
|
||||
if os.Getenv("GOOGLE_CLOUD_CREDENTIALS") == "" && os.Getenv("GOOGLE_CLOUD_CREDENTIALS_JSON") == "" {
|
||||
t.Skip("GOOGLE_CLOUD_CREDENTIALS_JSON not set, which should contain the credentials for testing")
|
||||
return
|
||||
}
|
||||
|
||||
projectID := os.Getenv("GOOGLE_CLOUD_PROJECT_ID")
|
||||
if projectID == "" {
|
||||
t.Skip("GOOGLE_CLOUD_PROJECT_ID not set, which should contain the GCP project ID for testing")
|
||||
return
|
||||
}
|
||||
|
||||
p, err := GCPSecretManager(projectID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
v, err := p.GetSecret("integration_test")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if string(v) != "This is a secret!" {
|
||||
t.Errorf("unexpected value %q", v)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user