Refactor streaming signatureV4 w/ state machine (#2862)

* Refactor streaming signatureV4 w/ state machine

- Used state machine to make transitions between reading chunk header,
  chunk data and trailer explicit.

* debug: add print/panic statements to gather more info on CI failure

* Persist lastChunk status between Read() on ChunkReader

... remove panic() which was added as interim aid for debugging.

* Add unit-tests to cover v4 streaming signature
This commit is contained in:
Krishnan Parthasarathi
2016-10-10 14:12:32 +05:30
committed by Harshavardhana
parent 3cfb23750a
commit 2d5e988a6d
5 changed files with 253 additions and 80 deletions

View File

@@ -136,8 +136,8 @@ func TestParseS3ChunkExtension(t *testing.T) {
}
}
// Test check CRLF characters on input reader.
func TestCheckCRLF(t *testing.T) {
// Test read CRLF characters on input reader.
func TestReadCRLF(t *testing.T) {
type testCase struct {
reader io.Reader
expectedErr error
@@ -153,7 +153,7 @@ func TestCheckCRLF(t *testing.T) {
{bytes.NewReader([]byte("h")), io.ErrUnexpectedEOF},
}
for i, tt := range tests {
err := checkCRLF(tt.reader)
err := readCRLF(tt.reader)
if err != tt.expectedErr {
t.Errorf("Test %d: Expected %s, got %s this", i+1, tt.expectedErr, err)
}