Пример #1
0
    opts['directory'] = 'tests'

# Need to allocate a queue; select some suboptions for the task
subopts = {'skip': lambda dt: hasattr(dt, 'must_skip') and dt.must_skip}
if 'maxth' in opts:
    subopts['maxth'] = opts['maxth']
if 'output' in opts:
    subopts['output'] = opts['output']
queue = dtest.DTestQueue(**subopts)

# OK, we need to do the explore
dtest.explore(opts['directory'], queue)

# Now, set up the dependency between tests.tearDown and our
# test_ordering() test and the test_partner_*() tests
dtest.depends(sys.modules['tests'].tearDown)(test_ordering)
dtest.depends(sys.modules['tests'].tearDown)(test_partner_setUp)
dtest.depends(sys.modules['tests'].tearDown)(test_partner_tearDown)

# Have to add local tests to tests set
queue.add_test(test_ordering)
queue.add_test(test_discovery)
queue.add_test(test_partner_setUp)
queue.add_test(test_partner_tearDown)

# Implement the rest of dtest.main()
if not opts.get('dryrun', False):
    # Execute the tests
    result = queue.run(opts.get('debug', False))
else:
    result = True
Пример #2
0

class AuthenticateTest(base.BaseKeystoneTest):
    def test_authenticate(self):
        """Test that we can authenticate using Keystone."""

        # Issue the authentication request
        resp = self.ks.authenticate(base.options.username,
                                    base.options.password)

        # Verify that resp is correct
        util.assert_equal(resp.status, 200)
        util.assert_in('auth', resp.obj)
        util.assert_in('token', resp.obj['auth'])
        util.assert_in('expires', resp.obj['auth']['token'])
        util.assert_in('id', resp.obj['auth']['token'])
        # util.assert_in('user', resp.obj['auth'])
        # util.assert_in('username', resp.obj['auth']['user'])
        # util.assert_in('tenantId', resp.obj['auth']['user'])
        # util.assert_equal(resp.obj['auth']['user']['username'],
        #                  base.options.username)

        # Now ensure we can revoke an authentication token
        auth_tok = resp.obj['auth']['token']['id']
        resp = self.ks.revoke_token(auth_tok, auth_tok)
        util.assert_equal(resp.status, 204)


# Ensure that all remaining tests wait for test_authenticate
dtest.depends(AuthenticateTest.test_authenticate)(base.KeystoneTest.setUpClass)