github.com/pachyderm/pachyderm@v1.13.4/src/server/pkg/obj/testing/util.go (about) 1 package testing 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/pachyderm/pachyderm/src/client/pkg/require" 8 ) 9 10 // The Load.*Parameters functions in this file are where we get the credentials 11 // for running object client tests. These are sourced from your environment 12 // variables. You can provide these yourself, or Pachyderm employees may use the 13 // variables defined in the password manager under the secure note "Pachyderm CI 14 // Object Storage Credentials". These should all be scoped to the smallest set 15 // of permissions necessary, which is just object create/read/delete within a 16 // specific bucket. 17 18 // LoadAmazonParameters loads the test parameters for S3 object storage: 19 // id - the key id credential 20 // secret - the key secret credential 21 // bucket - the S3 bucket to issue requests towards 22 // region - the S3 region that the bucket is in 23 func LoadAmazonParameters(t *testing.T) (string, string, string, string) { 24 id := os.Getenv("AMAZON_CLIENT_ID") 25 secret := os.Getenv("AMAZON_CLIENT_SECRET") 26 bucket := os.Getenv("AMAZON_CLIENT_BUCKET") 27 region := os.Getenv("AMAZON_CLIENT_REGION") 28 require.NotEqual(t, "", id) 29 require.NotEqual(t, "", secret) 30 require.NotEqual(t, "", bucket) 31 require.NotEqual(t, "", region) 32 33 return id, secret, bucket, region 34 } 35 36 // LoadECSParameters loads the test parameters for ECS object storage 37 // (credentials can be requested for a new account from portal.ecstestdrive.com): 38 // id - the key id credential 39 // secret - the key secret credential 40 // bucket - the ECS bucket to issue requests towards 41 // region - a dummy region - some clients require this but it is unused with 'endpoint' 42 // endpoint - the S3-compatible server to send requests to 43 func LoadECSParameters(t *testing.T) (string, string, string, string, string) { 44 id := os.Getenv("ECS_CLIENT_ID") 45 secret := os.Getenv("ECS_CLIENT_SECRET") 46 bucket := os.Getenv("ECS_CLIENT_BUCKET") 47 endpoint := os.Getenv("ECS_CLIENT_CUSTOM_ENDPOINT") 48 require.NotEqual(t, "", id) 49 require.NotEqual(t, "", secret) 50 require.NotEqual(t, "", bucket) 51 require.NotEqual(t, "", endpoint) 52 53 return id, secret, bucket, "dummy-region", endpoint 54 } 55 56 // LoadGoogleParameters loads the test parameters for GCS object storage: 57 // bucket - the GCS bucket to issue requests towards 58 // creds - the JSON GCP credentials to use 59 func LoadGoogleParameters(t *testing.T) (string, string) { 60 bucket := os.Getenv("GOOGLE_CLIENT_BUCKET") 61 creds := os.Getenv("GOOGLE_CLIENT_CREDS") 62 require.NotEqual(t, "", bucket) 63 require.NotEqual(t, "", creds) 64 65 return bucket, creds 66 } 67 68 // LoadGoogleHMACParameters loads the test parameters for GCS object storage, 69 // specifically for use with S3-compatible clients: 70 // id - the key id credential 71 // secret - the key secret credential 72 // bucket - the GCS bucket to issue requests towards 73 // region - the GCS region that the bucket is in 74 // endpoint - the S3-compatible server to send requests to 75 func LoadGoogleHMACParameters(t *testing.T) (string, string, string, string, string) { 76 id := os.Getenv("GOOGLE_CLIENT_HMAC_ID") 77 secret := os.Getenv("GOOGLE_CLIENT_HMAC_SECRET") 78 bucket := os.Getenv("GOOGLE_CLIENT_BUCKET") 79 region := os.Getenv("GOOGLE_CLIENT_REGION") 80 require.NotEqual(t, "", id) 81 require.NotEqual(t, "", secret) 82 require.NotEqual(t, "", bucket) 83 require.NotEqual(t, "", region) 84 85 return id, secret, bucket, region, "storage.googleapis.com" 86 } 87 88 // LoadMicrosoftParameters loads the test parameters for Azure blob storage: 89 // id - the key id credential 90 // secret - the key secret credential 91 // container - the Azure blob container to issue requests towards 92 func LoadMicrosoftParameters(t *testing.T) (string, string, string) { 93 id := os.Getenv("MICROSOFT_CLIENT_ID") 94 secret := os.Getenv("MICROSOFT_CLIENT_SECRET") 95 container := os.Getenv("MICROSOFT_CLIENT_CONTAINER") 96 require.NotEqual(t, "", id) 97 require.NotEqual(t, "", secret) 98 require.NotEqual(t, "", container) 99 100 return id, secret, container 101 }