Skip to content

Commit b7a1a33

Browse files
committed
test(appsec): trim redundant decoder tests from FileItemContentReaderTest
Charset fallback scenarios are covered by MultipartContentDecoderTest. One integration test is kept to verify that getContentType() is passed through.
1 parent 21b3820 commit b7a1a33

1 file changed

Lines changed: 1 addition & 29 deletions

File tree

dd-java-agent/instrumentation/commons-fileupload-1.5/src/test/groovy/FileItemContentReaderTest.groovy

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FileItemContentReaderTest extends Specification {
3939
FileItemContentReader.readContent(item) == ''
4040
}
4141

42-
void 'readContent decodes UTF-8 when Content-Type specifies charset=UTF-8'() {
42+
void 'readContent uses Content-Type from file item for charset decoding'() {
4343
given:
4444
def text = 'héllo wörld'
4545
def item = fileItemFromBytes(text.getBytes('UTF-8'), 'file.txt', 'text/plain; charset=UTF-8')
@@ -48,34 +48,6 @@ class FileItemContentReaderTest extends Specification {
4848
FileItemContentReader.readContent(item) == text
4949
}
5050

51-
void 'readContent falls back to UTF-8 when Content-Type has no charset'() {
52-
given:
53-
def text = 'hello world'
54-
def item = fileItemFromBytes(text.getBytes('UTF-8'), 'file.txt', 'text/plain')
55-
56-
expect:
57-
FileItemContentReader.readContent(item) == text
58-
}
59-
60-
void 'readContent falls back to UTF-8 when Content-Type is null'() {
61-
given:
62-
def text = 'hello world'
63-
def item = fileItemFromBytes(text.getBytes('UTF-8'), 'file.txt', null)
64-
65-
expect:
66-
FileItemContentReader.readContent(item) == text
67-
}
68-
69-
void 'readContent falls back to ISO-8859-1 when bytes are invalid UTF-8'() {
70-
given:
71-
// 0xE9 is 'é' in ISO-8859-1 but an invalid lone UTF-8 byte
72-
byte[] iso88591Bytes = 'café'.getBytes('ISO-8859-1')
73-
def item = fileItemFromBytes(iso88591Bytes, 'file.txt', null)
74-
75-
expect:
76-
FileItemContentReader.readContent(item) == 'café'
77-
}
78-
7951
void 'readContents returns content for each non-form file with a name'() {
8052
given:
8153
def items = [fileItem('content-a', 'file-a.txt'), fileItem('content-b', 'file-b.txt'),]

0 commit comments

Comments
 (0)