2018-05-16 15:26:11 +00:00
|
|
|
package tests
|
2018-05-10 23:05:43 +00:00
|
|
|
|
2018-05-14 18:11:18 +00:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-10-15 21:38:02 +00:00
|
|
|
"git.openprivacy.ca/openprivacy/bine/tor"
|
2018-05-14 18:11:18 +00:00
|
|
|
)
|
2018-05-10 23:05:43 +00:00
|
|
|
|
|
|
|
func TestAuthenticateNull(t *testing.T) {
|
2018-05-14 18:11:18 +00:00
|
|
|
ctx := NewTestContext(t, &tor.StartConf{DisableCookieAuth: true, DisableEagerAuth: true})
|
|
|
|
defer ctx.Close()
|
2018-05-11 17:34:33 +00:00
|
|
|
// Verify auth methods before auth
|
2018-05-14 18:11:18 +00:00
|
|
|
info, err := ctx.Control.ProtocolInfo()
|
2018-05-11 17:34:33 +00:00
|
|
|
ctx.Require.NoError(err)
|
|
|
|
ctx.Require.ElementsMatch([]string{"NULL"}, info.AuthMethods)
|
2018-05-14 18:11:18 +00:00
|
|
|
ctx.Require.NoError(ctx.Control.Authenticate(""))
|
2018-05-10 23:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAuthenticateSafeCookie(t *testing.T) {
|
2018-05-14 18:11:18 +00:00
|
|
|
ctx := NewTestContext(t, &tor.StartConf{DisableEagerAuth: true})
|
|
|
|
defer ctx.Close()
|
2018-05-11 17:34:33 +00:00
|
|
|
// Verify auth methods before auth
|
2018-05-14 18:11:18 +00:00
|
|
|
info, err := ctx.Control.ProtocolInfo()
|
2018-05-11 17:34:33 +00:00
|
|
|
ctx.Require.NoError(err)
|
|
|
|
ctx.Require.ElementsMatch([]string{"COOKIE", "SAFECOOKIE"}, info.AuthMethods)
|
2018-05-14 18:11:18 +00:00
|
|
|
ctx.Require.NoError(ctx.Control.Authenticate(""))
|
2018-05-10 23:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAuthenticateHashedPassword(t *testing.T) {
|
|
|
|
// "testpass" - 16:5417AE717521511A609921392778FFA8518EC089BF2162A199241AEB4A
|
2018-05-14 18:11:18 +00:00
|
|
|
ctx := NewTestContext(t, &tor.StartConf{
|
|
|
|
DisableCookieAuth: true,
|
|
|
|
DisableEagerAuth: true,
|
|
|
|
ExtraArgs: []string{"--HashedControlPassword", "16:5417AE717521511A609921392778FFA8518EC089BF2162A199241AEB4A"},
|
|
|
|
})
|
|
|
|
defer ctx.Close()
|
2018-05-11 17:34:33 +00:00
|
|
|
// Verify auth methods before auth
|
2018-05-14 18:11:18 +00:00
|
|
|
info, err := ctx.Control.ProtocolInfo()
|
2018-05-11 17:34:33 +00:00
|
|
|
ctx.Require.NoError(err)
|
2018-05-11 19:43:58 +00:00
|
|
|
ctx.Require.ElementsMatch([]string{"HASHEDPASSWORD"}, info.AuthMethods)
|
2018-05-14 18:11:18 +00:00
|
|
|
ctx.Require.NoError(ctx.Control.Authenticate("testpass"))
|
2018-05-10 23:05:43 +00:00
|
|
|
}
|