コード例 #1
0
def test_dispatch_role_present(mock_ensure_role_exists):
    """ dispatch with tenant, user and role"""
    keystone = setup_tenant_user_role()
    mock_ensure_role_exists.return_value = (True,
                                       "7df22b53d9c4405f92032c802178a31e")

    # Code under test
    res = keystone_user.dispatch(keystone, tenant="acme", user="******",
                                 role="admin")

    # Assertions
    mock_ensure_role_exists.assert_called_with(keystone, "root",
                                               "acme", "admin", False)
    assert (res == dict(changed=True, id="7df22b53d9c4405f92032c802178a31e"))
コード例 #2
0
def test_dispatch_tenant_when_present(mock_ensure_tenant_exists):
    """ dispatch with tenant only"""
    # Setup
    keystone = setup_tenant_user_role()
    mock_ensure_tenant_exists.return_value = (True,
                                       "34469137412242129cd908e384717794")

    # Code under test
    res = keystone_user.dispatch(keystone, tenant="bar",
                           tenant_description="This is a bar")

    # Assertions
    mock_ensure_tenant_exists.assert_called_with(keystone, "bar",
                                                "This is a bar", False)
    assert (res == dict(changed=True, id="34469137412242129cd908e384717794"))
コード例 #3
0
def test_dispatch_role_present(mock_ensure_role_exists):
    """ dispatch with tenant, user and role"""
    keystone = setup_tenant_user_role()
    mock_ensure_role_exists.return_value = (True,
                                       "7df22b53d9c4405f92032c802178a31e")

    # Code under test
    res = keystone_user.dispatch(keystone, tenant="acme", user="******",
                                 role="admin")

    # Assertions
    mock_ensure_role_exists.assert_called_with(keystone, "root",
                                               "acme", "admin", False)
    assert_equal(res,
        dict(changed=True, id="7df22b53d9c4405f92032c802178a31e"))
コード例 #4
0
def test_dispatch_tenant_when_present(mock_ensure_tenant_exists):
    """ dispatch with tenant only"""
    # Setup
    keystone = setup_tenant_user_role()
    mock_ensure_tenant_exists.return_value = (True,
                                       "34469137412242129cd908e384717794")

    # Code under test
    res = keystone_user.dispatch(keystone, tenant="bar",
                           tenant_description="This is a bar")

    # Assertions
    mock_ensure_tenant_exists.assert_called_with(keystone, "bar",
                                                "This is a bar", False)
    assert_equal(res,
        dict(changed=True, id="34469137412242129cd908e384717794"))
コード例 #5
0
def test_dispatch_user_when_present(mock_ensure_user_exists):
    """ dispatch with tenant and user"""
    # Setup
    keystone = setup_tenant_user_role()
    mock_ensure_user_exists.return_value = (True,
                                       "0a6f3697fc314279b1a22c61d40c0919")

    # Code under test
    res = keystone_user.dispatch(keystone, tenant="acme", user="******",
                                 email="*****@*****.**",
                                 password="******")

    # Assertions
    mock_ensure_user_exists.assert_called_with(keystone, "root",
                                               "12345", "*****@*****.**",
                                               "acme", False)

    assert (res == dict(changed=True, id="0a6f3697fc314279b1a22c61d40c0919"))
コード例 #6
0
def test_dispatch_user_when_present(mock_ensure_user_exists):
    """ dispatch with tenant and user"""
    # Setup
    keystone = setup_tenant_user_role()
    mock_ensure_user_exists.return_value = (True,
                                       "0a6f3697fc314279b1a22c61d40c0919")

    # Code under test
    res = keystone_user.dispatch(keystone, tenant="acme", user="******",
                                 email="*****@*****.**",
                                 password="******")

    # Assertions
    mock_ensure_user_exists.assert_called_with(keystone, "root",
                                               "12345", "*****@*****.**",
                                               "acme", False)

    assert_equal(res,
        dict(changed=True, id="0a6f3697fc314279b1a22c61d40c0919"))