From b01a9720763981c0935720284cacd8b4697b5efa Mon Sep 17 00:00:00 2001 From: v2ray Date: Mon, 8 Aug 2016 22:47:59 +0200 Subject: [PATCH] test for all authenticators --- transport/internet/authenticator.go | 2 +- transport/internet/authenticator_test.go | 27 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 transport/internet/authenticator_test.go diff --git a/transport/internet/authenticator.go b/transport/internet/authenticator.go index b6eea637..820aa4b3 100644 --- a/transport/internet/authenticator.go +++ b/transport/internet/authenticator.go @@ -41,7 +41,7 @@ func CreateAuthenticator(name string, config AuthenticatorConfig) (Authenticator if !found { return nil, ErrAuthenticatorNotFound } - return factory.Create(config.(AuthenticatorConfig)), nil + return factory.Create(config), nil } func CreateAuthenticatorConfig(rawConfig []byte) (string, AuthenticatorConfig, error) { diff --git a/transport/internet/authenticator_test.go b/transport/internet/authenticator_test.go new file mode 100644 index 00000000..ce8d0871 --- /dev/null +++ b/transport/internet/authenticator_test.go @@ -0,0 +1,27 @@ +package internet_test + +import ( + "testing" + + "github.com/v2ray/v2ray-core/testing/assert" + . "github.com/v2ray/v2ray-core/transport/internet" + _ "github.com/v2ray/v2ray-core/transport/internet/authenticators/noop" + _ "github.com/v2ray/v2ray-core/transport/internet/authenticators/srtp" + _ "github.com/v2ray/v2ray-core/transport/internet/authenticators/utp" +) + +func TestAllAuthenticatorLoadable(t *testing.T) { + assert := assert.On(t) + + noopAuth, err := CreateAuthenticator("none", nil) + assert.Error(err).IsNil() + assert.Int(noopAuth.Overhead()).Equals(0) + + srtp, err := CreateAuthenticator("srtp", nil) + assert.Error(err).IsNil() + assert.Int(srtp.Overhead()).Equals(4) + + utp, err := CreateAuthenticator("utp", nil) + assert.Error(err).IsNil() + assert.Int(utp.Overhead()).Equals(4) +}