Esempio n. 1
0
 def test_xcdbm(self):
     args = get_args('/var/log/xcauth', None, None, 'xcdbm',
         config_file_contents='#',
         args=['-b', '/tmp/domdb.db',
               '--secret', '012345678',
               '--url', 'https://unconfigured.example.ch',
               '--unload'])
 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)
Esempio n. 3
0
 def test_xcauth_exit_b(self):
     self.stub_stdouts()
     try:
         args = get_args('/var/log/xcauth', None, None, 'xcauth',
             config_file_contents='#',
             args=['-b', '/tmp/domdb.db',
                   '--secret', '012345678',
                   '--url', 'https://unconfigured.example.ch',
                   '--cache-query-ttl', '3600'])
         assert False # Should exit(1)
     except SystemExit:
         pass
Esempio n. 4
0
 def test_xcauth_timeout(self):
     args = get_args('/var/log/xcauth', None, None, 'xcauth',
         config_file_contents='#',
         args=['-b', '/tmp/domdb.db',
               '--secret', '012345678',
               '--url', 'https://unconfigured.example.ch',
               '--type', 'generic',
               '--timeout', '1,2',
               '--cache-unreachable-ttl', '1w',
               '--cache-query-ttl', '3600'])
     print args.timeout
     assert args.timeout == (1, 2)
Esempio n. 5
0
 def test_xcauth_crash_timeout(self):
     self.stub_stdouts()
     try:
         args = get_args('/var/log/xcauth', None, None, 'xcauth',
             config_file_contents='#',
             args=['-b', '/tmp/domdb.db',
                   '--secret', '012345678',
                   '--ejabberdctl', '012345678',
                   '--url', 'https://unconfigured.example.ch',
                   '--type', 'generic',
                   '--timeout', '1,2,3',
                   '--cache-unreachable-ttl', '1w',
                   '--cache-query-ttl', '3600'])
         assert False # Should raise ValueError
     except ValueError:
         pass
Esempio n. 6
0
 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 ')
Esempio n. 7
0
 def test_xcauth_timeout(self):
     args = get_args('/var/log/xcauth',
                     None,
                     None,
                     'xcauth',
                     config_file_contents='#',
                     args=[
                         '-b', '/tmp/domdb.db', '--secret', '012345678',
                         '--url', 'https://unconfigured.example.ch',
                         '--type', 'generic', '--timeout', '1,2',
                         '--cache-bcrypt-rounds', '8,4',
                         '--cache-unreachable-ttl', '1w',
                         '--cache-query-ttl', '3600'
                     ])
     print(args.timeout)
     self.assertEqual(args.timeout, (1, 2))
     self.assertEqual(args.cache_bcrypt_rounds, (8, 4))
Esempio n. 8
0
 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
Esempio n. 9
0
#!/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
Esempio n. 10
0
 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
Esempio n. 11
0
#!/usr/bin/python -tt

from xclib.configuration import get_args
from xclib.dbmops import perform

DESC = '''XMPP server authentication against JSXC>=3.2.0 on Nextcloud: Database manipulation.
    See https://jsxc.org or https://github.com/jsxc/xmpp-cloud-auth.'''
EPILOG = '''Exactly one of -G, -P, -D, -L, and -U is required.'''

if __name__ == '__main__':
    args = get_args(None, DESC, EPILOG, 'xcdbm')
    perform(args)

# vim: tabstop=8 softtabstop=0 expandtab shiftwidth=4