Ejemplo n.º 1
0
 def setUp(self):
     self.conn = SwiftConnection('http://127.0.0.1:8080/auth/v1.0',
                                 'username',
                                 'api_key',
                                 extra_headers={'extra': 'header'},
                                 verbose=True)
     self.agent = StubWebAgent()
     self.conn.agent = self.agent
     self.conn.storage_url = 'http://127.0.0.1:8080/v1/AUTH_user'
     self.conn.auth_token = 'TOKEN_123'
Ejemplo n.º 2
0
def get_swift_client(config, pool=None):
    for key in 'account username password'.split():
        if key not in config:
            raise unittest.SkipTest("%s not set in the test config file" % key)
    protocol = 'http'
    if config.get('auth_ssl', 'no').lower() in ('yes', 'true', 'on', '1'):
        protocol = 'https'
    host = config.get('auth_host', '127.0.0.1')
    port = config.get('auth_port', '8080')
    auth_prefix = config.get('auth_prefix', '/auth/')
    auth_url = '%s://%s:%s%sv1.0' % (protocol, host, port, auth_prefix)
    username = "******" % (config['account'], config['username'])
    api_key = config['password']
    return SwiftConnection(auth_url, username, api_key, pool=pool)
Ejemplo n.º 3
0
    def test_init(self):
        conn = SwiftConnection('http://127.0.0.1:8080/auth/v1.0', 'username',
                               'api_key')
        self.assertEqual(conn.auth_url, 'http://127.0.0.1:8080/auth/v1.0')
        self.assertEqual(conn.username, 'username')
        self.assertEqual(conn.api_key, 'api_key')
        self.assertEqual(conn.auth_token, None)
        self.assertEqual(conn.verbose, False)
        self.assertIsNotNone(conn.agent)

        pool = MagicMock()
        conn = SwiftConnection('http://127.0.0.1:8080/auth/v1.0',
                               'username',
                               'api_key',
                               pool=pool,
                               verbose=True)
        self.assertEqual(conn.auth_url, 'http://127.0.0.1:8080/auth/v1.0')
        self.assertEqual(conn.username, 'username')
        self.assertEqual(conn.api_key, 'api_key')
        self.assertEqual(conn.auth_token, None)
        self.assertEqual(conn.verbose, True)
        self.assertIsNotNone(conn.agent)
        self.assertEqual(conn.pool, pool)