Exemple #1
0
func (s *ConnectionPolicySuite) Test_buildDialerFor_ErrorsIfTorIsRequiredButNotFound(c *C) {
	account := &Account{
		Account:    "*****@*****.**",
		RequireTor: true,
	}

	policy := ConnectionPolicy{
		torState: nettest.MockTorState(""),
	}

	_, err := policy.buildDialerFor(account)

	c.Check(err, Equals, ErrTorNotRunning)
}
Exemple #2
0
func (s *ConnectionPolicySuite) Test_buildDialerFor_UsesAssociatedHiddenServiceIfFound(c *C) {
	account := &Account{
		Account: "*****@*****.**",

		RequireTor: true,
	}

	policy := ConnectionPolicy{
		torState: nettest.MockTorState("127.0.0.1:9999"),
	}
	dialer, err := policy.buildDialerFor(account)

	c.Check(err, IsNil)
	c.Check(dialer.ServerAddress, Equals, "4cjw6cwpeaeppfqz.onion:5222")
}
Exemple #3
0
func (s *ConnectionPolicySuite) Test_buildDialerFor_EnforcesTorProxyOnAccountIfRequired(c *C) {
	account := &Account{
		Account:    "*****@*****.**",
		RequireTor: true,
	}

	policy := ConnectionPolicy{
		torState: nettest.MockTorState("127.0.0.1:9999"),
	}

	c.Check(account.Proxies, HasLen, 0)

	_, err := policy.buildDialerFor(account)

	c.Check(err, IsNil)
	c.Check(account.Proxies, HasLen, 1)
}