MCPcopy
hub / github.com/minio/minio-go / TestFileMinioClient

Function TestFileMinioClient

pkg/credentials/file_test.go:150–214  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestFileMinioClient(t *testing.T) {
151 os.Clearenv()
152
153 creds := NewFileMinioClient("config.json.sample", "")
154 credValues, err := creds.GetWithContext(defaultCredContext)
155 if err != nil {
156 t.Fatal(err)
157 }
158
159 if credValues.AccessKeyID != "accessKey" {
160 t.Errorf("Expected 'accessKey', got %s'", credValues.AccessKeyID)
161 }
162 if credValues.SecretAccessKey != "secret" {
163 t.Errorf("Expected 'secret', got %s'", credValues.SecretAccessKey)
164 }
165 if credValues.SignerType != SignatureV4 {
166 t.Errorf("Expected 'S3v4', got %s'", credValues.SignerType)
167 }
168
169 os.Clearenv()
170 t.Setenv("MINIO_ALIAS", "play")
171
172 creds = NewFileMinioClient("config.json.sample", "")
173 credValues, err = creds.GetWithContext(defaultCredContext)
174 if err != nil {
175 t.Fatal(err)
176 }
177
178 if credValues.AccessKeyID != "Q3AM3UQ867SPQQA43P2F" {
179 t.Errorf("Expected 'Q3AM3UQ867SPQQA43P2F', got %s'", credValues.AccessKeyID)
180 }
181 if credValues.SecretAccessKey != "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" {
182 t.Errorf("Expected 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG', got %s'", credValues.SecretAccessKey)
183 }
184 if credValues.SignerType != SignatureV2 {
185 t.Errorf("Expected 'S3v2', got %s'", credValues.SignerType)
186 }
187
188 os.Clearenv()
189
190 creds = NewFileMinioClient("config.json.sample", "play")
191 credValues, err = creds.GetWithContext(defaultCredContext)
192 if err != nil {
193 t.Fatal(err)
194 }
195
196 if credValues.AccessKeyID != "Q3AM3UQ867SPQQA43P2F" {
197 t.Errorf("Expected 'Q3AM3UQ867SPQQA43P2F', got %s'", credValues.AccessKeyID)
198 }
199 if credValues.SecretAccessKey != "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" {
200 t.Errorf("Expected 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG', got %s'", credValues.SecretAccessKey)
201 }
202 if credValues.SignerType != SignatureV2 {
203 t.Errorf("Expected 'S3v2', got %s'", credValues.SignerType)
204 }
205
206 creds = NewFileMinioClient("non-existent.json", "play")
207 _, err = creds.GetWithContext(defaultCredContext)

Callers

nothing calls this directly

Calls 4

IsExpiredMethod · 0.95
NewFileMinioClientFunction · 0.85
GetWithContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected