Skip to content

Commit a9dec07

Browse files
authored
fix(storage): Avoid integration test segfaults. (#12419)
* fix(storage): Avoid integration test segfaults. If the JWT private key file is not specified in an environment variable, then skip the tests which would otherwise require it. This matches what other tests do. Without this change, `jwt.Email` results in a nil dereference. * fix typo * Move from skip to fatal
1 parent f1461af commit a9dec07

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

storage/integration_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,7 +2682,7 @@ func TestIntegration_SignedURL(t *testing.T) {
26822682
t.Fatal(err)
26832683
}
26842684
if jwtConf == nil {
2685-
t.Skip("JSON key file is not present")
2685+
t.Fatal("JSON key file is not present")
26862686
}
26872687

26882688
bkt := client.Bucket(bucket)
@@ -2803,7 +2803,7 @@ func TestIntegration_SignedURL_WithEncryptionKeys(t *testing.T) {
28032803
t.Fatal(err)
28042804
}
28052805
if jwtConf == nil {
2806-
t.Skip("JSON key file is not present")
2806+
t.Fatal("JSON key file is not present")
28072807
}
28082808

28092809
bkt := client.Bucket(bucket)
@@ -2890,7 +2890,7 @@ func TestIntegration_SignedURL_EmptyStringObjectName(t *testing.T) {
28902890
t.Fatal(err)
28912891
}
28922892
if jwtConf == nil {
2893-
t.Skip("JSON key file is not present")
2893+
t.Fatal("JSON key file is not present")
28942894
}
28952895

28962896
opts := &SignedURLOptions{
@@ -4048,6 +4048,10 @@ func TestIntegration_RequesterPaysOwner(t *testing.T) {
40484048
if err != nil {
40494049
t.Fatalf("testutil.JWTConfig: %v", err)
40504050
}
4051+
if jwt == nil {
4052+
t.Fatal("JSON key file is not present")
4053+
}
4054+
40514055
// an account that has permissions on the project that owns the bucket
40524056
mainUserEmail := jwt.Email
40534057

@@ -6468,7 +6472,7 @@ func TestIntegration_PostPolicyV4(t *testing.T) {
64686472
t.Fatal(err)
64696473
}
64706474
if jwtConf == nil {
6471-
t.Skip("JSON key file is not present")
6475+
t.Fatal("JSON key file is not present")
64726476
}
64736477

64746478
projectID := testutil.ProjID()
@@ -6651,6 +6655,9 @@ func TestIntegration_SignedURL_DefaultSignBytes(t *testing.T) {
66516655
if err != nil {
66526656
t.Fatalf("unable to find test credentials: %v", err)
66536657
}
6658+
if jwt == nil {
6659+
t.Fatal("JSON key file is not present")
6660+
}
66546661

66556662
obj := "testBucketSignedURL"
66566663
contents := []byte("test")
@@ -6745,6 +6752,9 @@ func TestIntegration_PostPolicyV4_BucketDefault(t *testing.T) {
67456752
if err != nil {
67466753
t.Fatalf("unable to find test credentials: %v", err)
67476754
}
6755+
if jwt == nil {
6756+
t.Fatal("JSON key file is not present")
6757+
}
67486758

67496759
statusCodeToRespond := 200
67506760

@@ -6810,7 +6820,7 @@ func TestIntegration_PostPolicyV4_SignedURL_WithSignBytes(t *testing.T) {
68106820
t.Fatal(err)
68116821
}
68126822
if jwtConf == nil {
6813-
t.Skip("JSON key file is not present")
6823+
t.Fatal("JSON key file is not present")
68146824
}
68156825

68166826
signingFunc := func(b []byte) ([]byte, error) {

0 commit comments

Comments
 (0)