config_json_test.go 576 B

123456789101112131415161718192021222324252627
  1. // +build json
  2. package shadowsocks
  3. import (
  4. "encoding/json"
  5. "testing"
  6. v2testing "github.com/v2ray/v2ray-core/testing"
  7. "github.com/v2ray/v2ray-core/testing/assert"
  8. )
  9. func TestConfigParsing(t *testing.T) {
  10. v2testing.Current(t)
  11. rawJson := `{
  12. "method": "aes-128-cfb",
  13. "password": "v2ray-password"
  14. }`
  15. config := new(Config)
  16. err := json.Unmarshal([]byte(rawJson), config)
  17. assert.Error(err).IsNil()
  18. assert.Int(config.Cipher.KeySize()).Equals(16)
  19. assert.Bytes(config.Key).Equals([]byte{160, 224, 26, 2, 22, 110, 9, 80, 65, 52, 80, 20, 38, 243, 224, 241})
  20. }