def test_form_button_validation(request, user1, setup_infra_provider):
    set_vm_to_user = Vm('cu-9-5', setup_infra_provider)
    # Reset button test
    set_vm_to_user.set_ownership(user=user1.name, click_reset=True)
    # Cancel button test
    set_vm_to_user.set_ownership(user=user1.name, click_cancel=True)
    # Save button test
    set_vm_to_user.set_ownership(user=user1.name)
    # Unset the ownership
    set_vm_to_user.unset_ownership()
def test_group_ownership_on_user_or_group_role(request, user3,
                                               setup_infra_provider):
    set_vm_to_group = Vm('cu-9-5', setup_infra_provider)
    set_vm_to_group.set_ownership(group=user3.group.description)
    login.login(user3.credential.principal, user3.credential.secret)
    assert (set_vm_to_group.does_vm_exist_in_cfme(), "vm not found")
    # Unset the ownership
    login.login_admin()
    set_vm_to_group.unset_ownership()
    login.login(user3.credential.principal, user3.credential.secret)
    assert (not set_vm_to_group.does_vm_exist_in_cfme(), "vm exists")
def test_user_ownership_crud(request, user1, setup_infra_provider):
    set_vm_to_user = Vm('cu-9-5', setup_infra_provider)
    # Set the ownership and checking it
    set_vm_to_user.set_ownership(user=user1.name)
    login.login(user1.credential.principal, user1.credential.secret)
    assert (set_vm_to_user.does_vm_exist_in_cfme(), "vm not found")
    # Unset the ownership
    login.login_admin()
    set_vm_to_user.unset_ownership()
    login.login(user1.credential.principal, user1.credential.secret)
    assert (not set_vm_to_user.does_vm_exist_in_cfme(), "vm exists")
def test_ownership_transfer(request, user1, user3, setup_infra_provider):
    set_vm_to_user = Vm('cu-9-5', setup_infra_provider)
    # Setting ownership
    login.login_admin()
    set_vm_to_user.set_ownership(user=user1.name)
    login.login(user1.credential.principal, user1.credential.secret)
    # Checking before and after the ownership transfer
    assert (set_vm_to_user.does_vm_exist_in_cfme(), "vm not found")
    set_vm_to_user.set_ownership(user=user3.name)
    assert (not set_vm_to_user.does_vm_exist_in_cfme(), "vm exists")
    login.login(user3.credential.principal, user3.credential.secret)
    assert (set_vm_to_user.does_vm_exist_in_cfme(), "vm not found")
    # Unset the ownership
    login.login_admin()
    set_vm_to_user.unset_ownership()
    login.login(user3.credential.principal, user3.credential.secret)
    assert (set_vm_to_user.does_vm_exist_in_cfme(), "vm exists")