v2ray-core/proxy/shadowsocks/config_json_test.go

33 lines
690 B
Go
Raw Normal View History

2016-01-28 12:40:00 +00:00
// +build json
package shadowsocks
import (
"encoding/json"
"testing"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/testing/assert"
2016-01-28 12:40:00 +00:00
)
func TestConfigParsing(t *testing.T) {
2016-05-24 19:55:46 +00:00
assert := assert.On(t)
2016-01-28 12:40:00 +00:00
rawJson := `{
"method": "aes-128-cfb",
"password": "v2ray-password"
}`
2016-09-25 20:19:49 +00:00
config := new(ServerConfig)
2016-01-28 12:40:00 +00:00
err := json.Unmarshal([]byte(rawJson), config)
assert.Error(err).IsNil()
2016-09-25 20:19:49 +00:00
account := new(Account)
_, err = config.User.GetTypedAccount(account)
2016-09-17 22:41:21 +00:00
assert.Error(err).IsNil()
2016-09-25 20:19:49 +00:00
cipher, err := account.GetCipher()
assert.Error(err).IsNil()
assert.Int(cipher.KeySize()).Equals(16)
assert.Bytes(account.GetCipherKey()).Equals([]byte{160, 224, 26, 2, 22, 110, 9, 80, 65, 52, 80, 20, 38, 243, 224, 241})
2016-01-28 12:40:00 +00:00
}