config_json_test.go 690 B

1234567891011121314151617181920212223242526272829303132
  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(ServerConfig)
  15. err := json.Unmarshal([]byte(rawJson), config)
  16. assert.Error(err).IsNil()
  17. account := new(Account)
  18. _, err = config.User.GetTypedAccount(account)
  19. assert.Error(err).IsNil()
  20. cipher, err := account.GetCipher()
  21. assert.Error(err).IsNil()
  22. assert.Int(cipher.KeySize()).Equals(16)
  23. assert.Bytes(account.GetCipherKey()).Equals([]byte{160, 224, 26, 2, 22, 110, 9, 80, 65, 52, 80, 20, 38, 243, 224, 241})
  24. }