Permalink
Please sign in to comment.
Browse files
Add flag to upload coverage insecurely
Add an `--insecure` flag to both the `after-build` and `upload-coverage` sub-commands to upload test coverage insecurely (without HTTPS). This is *not* recommended for general use. This is intended for use in private environments where the benefits of secure transfer outweigh the operational costs.
- Loading branch information...
Showing
with
76 additions
and 1 deletion.
- +3 −0 cmd/after-build.go
- +2 −0 cmd/upload-coverage.go
- +23 −1 upload/uploader.go
- +48 −0 upload/uploader_test.go
@@ -0,0 +1,48 @@ | |||
package upload | |||
|
|||
import ( | |||
"testing" | |||
|
|||
"github.com/stretchr/testify/require" | |||
) | |||
|
|||
func Test_TransformPostBatchURL_Secure(t *testing.T) { | |||
r := require.New(t) | |||
|
|||
uploader := Uploader{ | |||
Insecure: false, | |||
} | |||
|
|||
rawURL := "https://example.com/" | |||
actualURL, err := uploader.TransformPostBatchURL(rawURL) | |||
|
|||
r.Equal("https://example.com/", actualURL) | |||
r.Nil(err) | |||
} | |||
func Test_TransformPostBatchURL_Insecure_Success(t *testing.T) { | |||
r := require.New(t) | |||
|
|||
uploader := Uploader{ | |||
Insecure: true, | |||
} | |||
|
|||
rawURL := "https://example.com/" | |||
actualURL, err := uploader.TransformPostBatchURL(rawURL) | |||
|
|||
r.Equal("http://example.com/", actualURL) | |||
r.Nil(err) | |||
} | |||
|
|||
func Test_TransformPostBatchURL_Insecure_Error(t *testing.T) { | |||
r := require.New(t) | |||
|
|||
uploader := Uploader{ | |||
Insecure: true, | |||
} | |||
|
|||
rawURL := "://example.com/" | |||
actualURL, err := uploader.TransformPostBatchURL(rawURL) | |||
|
|||
r.Equal("", actualURL) | |||
r.Equal("parse ://example.com/: missing protocol scheme", err.Error()) | |||
} |
0 comments on commit
2c088e1