def assert_matches_test_config(self, protocolinfo_response): """ Makes assertions that the protocolinfo response's attributes match those of the test configuration. """ runner = test.runner.get_runner() tor_options = runner.get_options() auth_methods, auth_cookie_path = [], None if test.runner.Torrc.COOKIE in tor_options: auth_methods.append(stem.response.protocolinfo.AuthMethod.COOKIE) chroot_path = runner.get_chroot() auth_cookie_path = runner.get_auth_cookie_path() if chroot_path and auth_cookie_path.startswith(chroot_path): auth_cookie_path = auth_cookie_path[len(chroot_path):] if test.runner.Torrc.PASSWORD in tor_options: auth_methods.append(stem.response.protocolinfo.AuthMethod.PASSWORD) if not auth_methods: auth_methods.append(stem.response.protocolinfo.AuthMethod.NONE) self.assertEqual((), protocolinfo_response.unknown_auth_methods) self.assertEqual(tuple(auth_methods), protocolinfo_response.auth_methods) self.assertEqual(auth_cookie_path, protocolinfo_response.cookie_path)
def assert_matches_test_config(self, protocolinfo_response): """ Makes assertions that the protocolinfo response's attributes match those of the test configuration. """ runner = test.runner.get_runner() tor_options = runner.get_options() auth_methods, auth_cookie_path = [], None if test.runner.Torrc.COOKIE in tor_options: auth_methods.append(stem.response.protocolinfo.AuthMethod.COOKIE) if test.tor_version() >= stem.version.Requirement.AUTH_SAFECOOKIE: auth_methods.append( stem.response.protocolinfo.AuthMethod.SAFECOOKIE) chroot_path = runner.get_chroot() auth_cookie_path = runner.get_auth_cookie_path() if chroot_path and auth_cookie_path.startswith(chroot_path): auth_cookie_path = auth_cookie_path[len(chroot_path):] if test.runner.Torrc.PASSWORD in tor_options: auth_methods.append(stem.response.protocolinfo.AuthMethod.PASSWORD) if not auth_methods: auth_methods.append(stem.response.protocolinfo.AuthMethod.NONE) self.assertEqual((), protocolinfo_response.unknown_auth_methods) self.assertEqual(tuple(auth_methods), protocolinfo_response.auth_methods) self.assertEqual(auth_cookie_path, protocolinfo_response.cookie_path)