cipher_test.go 765 B

12345678910111213141516171819202122232425262728293031323334
  1. package s3crypto_test
  2. import (
  3. "io/ioutil"
  4. "strings"
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. "github.com/aws/aws-sdk-go/service/s3/s3crypto"
  8. )
  9. func TestCryptoReadCloserRead(t *testing.T) {
  10. expectedStr := "HELLO WORLD "
  11. str := strings.NewReader(expectedStr)
  12. rc := &s3crypto.CryptoReadCloser{Body: ioutil.NopCloser(str), Decrypter: str}
  13. b, err := ioutil.ReadAll(rc)
  14. assert.NoError(t, err)
  15. assert.Equal(t, expectedStr, string(b))
  16. }
  17. func TestCryptoReadCloserClose(t *testing.T) {
  18. data := "HELLO WORLD "
  19. expectedStr := ""
  20. str := strings.NewReader(data)
  21. rc := &s3crypto.CryptoReadCloser{Body: ioutil.NopCloser(str), Decrypter: str}
  22. rc.Close()
  23. b, err := ioutil.ReadAll(rc)
  24. assert.NoError(t, err)
  25. assert.Equal(t, expectedStr, string(b))
  26. }