37 lines
736 B
Go
Raw Normal View History

2016-06-17 16:51:41 +02:00
package kcp_test
import (
"testing"
2016-08-20 20:55:45 +02:00
. "v2ray.com/core/transport/internet/kcp"
2017-10-26 21:44:22 +02:00
. "v2ray.com/ext/assert"
2016-06-17 16:51:41 +02:00
)
func TestSimpleAuthenticator(t *testing.T) {
2017-10-24 16:15:35 +02:00
assert := With(t)
2016-06-17 16:51:41 +02:00
2016-12-08 16:27:41 +01:00
cache := make([]byte, 512)
2016-06-17 16:51:41 +02:00
2016-12-08 16:27:41 +01:00
payload := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
2016-06-17 16:51:41 +02:00
2016-12-08 16:27:41 +01:00
auth := NewSimpleAuthenticator()
b := auth.Seal(cache[:0], nil, payload, nil)
c, err := auth.Open(cache[:0], nil, b, nil)
2017-10-24 16:15:35 +02:00
assert(err, IsNil)
assert(c, Equals, payload)
}
func TestSimpleAuthenticator2(t *testing.T) {
2017-10-24 16:15:35 +02:00
assert := With(t)
2016-12-08 16:27:41 +01:00
cache := make([]byte, 512)
2016-12-08 16:27:41 +01:00
payload := []byte{'a', 'b'}
auth := NewSimpleAuthenticator()
2016-12-08 16:27:41 +01:00
b := auth.Seal(cache[:0], nil, payload, nil)
c, err := auth.Open(cache[:0], nil, b, nil)
2017-10-24 16:15:35 +02:00
assert(err, IsNil)
assert(c, Equals, payload)
2016-06-17 16:51:41 +02:00
}