Stage uploads before accepting HTTP runs
This commit is contained in:
@@ -138,6 +138,11 @@ func validateRunID(value string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateContentType(contentType string) error {
|
||||
_, err := archiveFormat(contentType)
|
||||
return err
|
||||
}
|
||||
|
||||
type archiveKind int
|
||||
|
||||
const (
|
||||
|
||||
@@ -47,6 +47,25 @@ func TestStageArchiveRejectsUnsupportedContentType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateContentType(t *testing.T) {
|
||||
for _, contentType := range []string{
|
||||
ContentTypeTar,
|
||||
ContentTypeGzip,
|
||||
ContentTypeXGzip,
|
||||
ContentTypeGzip + "; charset=binary",
|
||||
} {
|
||||
t.Run(contentType, func(t *testing.T) {
|
||||
if err := ValidateContentType(contentType); err != nil {
|
||||
t.Fatalf("ValidateContentType() error = %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if err := ValidateContentType("application/zip"); !errors.Is(err, ErrUnsupportedContentType) {
|
||||
t.Fatalf("ValidateContentType() error = %v, want ErrUnsupportedContentType", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStageArchiveEnforcesMaxUploadSize(t *testing.T) {
|
||||
archive := validArchive(t, false)
|
||||
err := stageArchiveError(t, archive, ContentTypeTar, func(opts *StageOptions) {
|
||||
|
||||
Reference in New Issue
Block a user