Ejemplo n.º 1
0
def test__prepare_auth_v1():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 1.0
    version = '1.0'
    args = mock.Mock()
    args.auth = 'http://example.com/auth/v1.0'
    args.user = '******'
    args.key = 'secret'
    conn = None

    expected = {
        'version': '1.0',
        'authUrl': 'http://example.com/auth/v1.0',
        'username': '******',
        'password': '******',
    }
    assert zpm._prepare_auth(version, args, conn) == expected
    # Make sure that we're robust enough to handle slightly varied version
    # inputs.
    version = '1'
    assert zpm._prepare_auth(version, args, conn) == expected
Ejemplo n.º 2
0
def test__prepare_auth_v1():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 1.0
    version = '1.0'
    args = mock.Mock()
    args.auth = 'http://example.com/auth/v1.0'
    args.user = '******'
    args.key = 'secret'
    conn = None

    expected = {
        'version': '1.0',
        'authUrl': 'http://example.com/auth/v1.0',
        'username': '******',
        'password': '******',
    }
    assert zpm._prepare_auth(version, args, conn) == expected
    # Make sure that we're robust enough to handle slightly varied version
    # inputs.
    version = '1'
    assert zpm._prepare_auth(version, args, conn) == expected
Ejemplo n.º 3
0
def test__prepare_auth_v0():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 0.0
    version = '0.0'
    args = None
    conn = mock.Mock()
    conn.url = 'http://example.com'

    expected = {
        'version': '0.0',
        'swiftUrl': 'http://example.com',
    }
    assert zpm._prepare_auth(version, args, conn) == expected
Ejemplo n.º 4
0
def test__prepare_auth_v0():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 0.0
    version = '0.0'
    args = None
    conn = mock.Mock()
    conn.url = 'http://example.com'

    expected = {
        'version': '0.0',
        'swiftUrl': 'http://example.com',
    }
    assert zpm._prepare_auth(version, args, conn) == expected
Ejemplo n.º 5
0
def test__prepare_auth_v2():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 2.0
    version = '2.0'
    args = mock.Mock()
    args.os_auth_url = 'http://example.com:5000/v2.0'
    args.os_username = '******'
    args.os_tenant_name = 'tenant1'
    args.os_password = '******'
    conn = None

    expected = {
        'version': '2.0',
        'authUrl': 'http://example.com:5000/v2.0',
        'tenant': 'tenant1',
        'username': '******',
        'password': '******',
    }
    assert zpm._prepare_auth(version, args, conn) == expected
    # Make sure that we're robust enough to handle slightly varied version
    # inputs.
    version = '2'
    assert zpm._prepare_auth(version, args, conn) == expected
Ejemplo n.º 6
0
def test__prepare_auth_v2():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 2.0
    version = '2.0'
    args = mock.Mock()
    args.os_auth_url = 'http://example.com:5000/v2.0'
    args.os_username = '******'
    args.os_tenant_name = 'tenant1'
    args.os_password = '******'
    conn = None

    expected = {
        'version': '2.0',
        'authUrl': 'http://example.com:5000/v2.0',
        'tenant': 'tenant1',
        'username': '******',
        'password': '******',
    }
    assert zpm._prepare_auth(version, args, conn) == expected
    # Make sure that we're robust enough to handle slightly varied version
    # inputs.
    version = '2'
    assert zpm._prepare_auth(version, args, conn) == expected
Ejemplo n.º 7
0
def test__prepare_auth_v1():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 1.0
    version = '1.0'
    args = mock.Mock()
    args.auth = 'http://example.com/auth/v1.0'
    args.user = '******'
    args.key = 'secret'
    conn = None

    expected = {
        'version': '1.0',
        'authUrl': 'http://example.com/auth/v1.0',
        'username': '******',
        'password': '******',
    }
    assert zpm._prepare_auth(version, args, conn) == expected
Ejemplo n.º 8
0
    def setup_method(self, _method):
        self.conn = mock.Mock()
        self.conn.get_container.return_value = (
            {},  # response headers
            [],  # object list
        )

        self.target = 'container1/foo/bar'
        self.zapp_path = self.temp_zapp_file

        self.conn.url = 'http://example.com'
        args = mock.Mock()
        args.auth = 'http://example.com/auth/v1.0'
        args.user = '******'
        args.key = 'secret'
        self.auth_opts = jinja2.Markup(
            json.dumps(zpm._prepare_auth('1.0', args, self.conn)))
Ejemplo n.º 9
0
    def setup_method(self, _method):
        self.conn = mock.Mock()
        self.conn.get_container.return_value = (
            {},  # response headers
            [],  # object list
        )

        self.target = 'container1/foo/bar'
        self.zapp_path = self.temp_zapp_file

        self.conn.url = 'http://example.com'
        args = mock.Mock()
        args.auth = 'http://example.com/auth/v1.0'
        args.user = '******'
        args.key = 'secret'
        self.auth_opts = jinja2.Markup(
            json.dumps(zpm._prepare_auth('1.0', args, self.conn))
        )
Ejemplo n.º 10
0
def test__prepare_auth_v2():
    # Test for :func:`zpmlib.zpm._prepare_auth`, with version 2.0
    version = '2.0'
    args = mock.Mock()
    args.os_auth_url = 'http://example.com:5000/v2.0'
    args.os_username = '******'
    args.os_tenant_name = 'tenant1'
    args.os_password = '******'
    conn = None

    expected = {
        'version': '2.0',
        'authUrl': 'http://example.com:5000/v2.0',
        'tenant': 'tenant1',
        'username': '******',
        'password': '******',
    }
    assert zpm._prepare_auth(version, args, conn) == expected