config_json_test.go 529 B

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