config_json_test.go 656 B

12345678910111213141516171819202122232425262728
  1. // +build json
  2. package shadowsocks
  3. import (
  4. "encoding/json"
  5. "testing"
  6. "v2ray.com/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.GetCipher().KeySize()).Equals(16)
  18. account, err := config.User.GetTypedAccount(&Account{})
  19. assert.Error(err).IsNil()
  20. assert.Bytes(account.(*Account).GetCipherKey(config.GetCipher().KeySize())).Equals([]byte{160, 224, 26, 2, 22, 110, 9, 80, 65, 52, 80, 20, 38, 243, 224, 241})
  21. }