def command_line(self, options, expected): logging.info('command_line ' + str(options) + ' =? ' + expected) self.stub_stdout() args = get_args(None, None, None, 'xcauth', args=options) perform(args) output = sys.stdout.getvalue().rstrip('\n') self.assertEqual(output, expected)
def test_postfix_connection_error(self): self.stub_stdin('get [email protected]\n') self.stub_stdout() args = get_args(None, None, None, 'xcauth', args=[ '-t', 'postfix', '-u', 'https://no-connection.jsxc.org/', '-s', '0', '-l', dirname ], config_file_contents='#') perform(args) output = sys.stdout.getvalue().rstrip('\n') logging.debug(output) assertEqual(output[0:4], '400 ')
def generic_io(self, command, expected): self.stub_stdin(':'.join(command) + '\n') self.stub_stdout() args = get_args(None, None, None, 'xcauth', args=['-t', 'generic']) perform(args) output = sys.stdout.getvalue().rstrip('\n') logging.debug(output) logging.debug(expected) if output == '0' or output == 'None': assert str(expected) == 'False' or str(expected) == 'None' elif output == '1': assert str(expected) == 'True' else: # Only "roster" command will get here. # Convert both strs to dicts to avoid # problems with formatting (whitespace) and order. output = json.loads(output) expected = json.loads(expected) assert output == expected
#!/usr/bin/python3 -tt from xclib.configuration import get_args from xclib.authops import perform DEFAULT_LOG_DIR = '/var/log/xcauth' DESC = '''XMPP server authentication against JSXC>=3.2.0 on Nextcloud. See https://jsxc.org or https://github.com/jsxc/xmpp-cloud-auth.''' EPILOG = '''-I, -R, and -A take precedence over -t. One of them is required. -I, -R, and -A imply -i and -d.''' if __name__ == '__main__': args = get_args(DEFAULT_LOG_DIR, DESC, EPILOG, 'xcauth') perform(args) # vim: tabstop=8 softtabstop=0 expandtab shiftwidth=4
def command_line(self, options, expected): self.stub_stdout() args = get_args(None, None, None, 'xcauth', args=options) perform(args) output = sys.stdout.getvalue().rstrip('\n') assert output == expected