Exemplo n.º 1
0
def test_split_add_user():
    """
    Make sure split doesn't do anything when we have a non-add/remove group action
    :return:
    """
    user = UserAction(id_type=IdentityTypes.enterpriseID,
                      email="*****@*****.**")
    user.create(first_name="Example",
                last_name="User",
                country="US",
                email="*****@*****.**")
    user.update(first_name="EXAMPLE")
    assert user.maybe_split_groups(10) is False
    assert len(user.commands) == 2
    assert user.wire_dict() == {
        'do': [{
            'createEnterpriseID': {
                'country': 'US',
                'email': '*****@*****.**',
                'firstname': 'Example',
                'lastname': 'User',
                'option': 'ignoreIfAlreadyExists'
            }
        }, {
            'update': {
                'firstname': 'EXAMPLE'
            }
        }],
        'user':
        '******'
    }
Exemplo n.º 2
0
def test_different_email_username():
    """
    Update a user record so the email address is different than email-type username (federated only)
    """
    user = UserAction(id_type=IdentityTypes.federatedID, email="*****@*****.**")
    user.update(email="*****@*****.**", username="******")
    assert user.wire_dict() == {"do": [{"update": {"email": "*****@*****.**",
                                                   "username": "******"}}],
                                "user": "******"}
Exemplo n.º 3
0
def test_update_user_federatedid_username():
    user = UserAction(id_type=IdentityTypes.federatedID,
                      email="*****@*****.**")
    user.update(username="******")
    assert user.wire_dict() == {
        "do": [{
            "update": {
                "username": "******"
            }
        }],
        "user": "******"
    }
Exemplo n.º 4
0
def test_update_user_federatedid_unicode():
    user = UserAction(id_type=IdentityTypes.federatedID,
                      email="*****@*****.**")
    user.update(first_name=u"André", last_name="Danger")
    assert user.wire_dict() == {
        "do": [{
            "update": {
                "firstname": u"André",
                "lastname": "Danger"
            }
        }],
        "user": "******"
    }
Exemplo n.º 5
0
def test_update_user_adobeid():
    user = UserAction(id_type=IdentityTypes.adobeID,
                      email="*****@*****.**")
    user.update(first_name="Johnny", last_name="Danger")
    assert user.wire_dict() == {
        "do": [{
            "update": {
                "firstname": "Johnny",
                "lastname": "Danger"
            }
        }],
        "user": "******",
        "useAdobeID": True
    }
Exemplo n.º 6
0
    cols = ['Username', 'Email', 'New Email', 'New Username']

    actions = {}
    for user_rec in CSVAdapter.read_csv_rows(args.users_filename,
                                             recognized_column_names=cols):
        username, email, new_email, new_username, domain = \
            user_rec.get('Username'), user_rec.get('Email'), user_rec.get('New Email'),user_rec.get('New Username'), user_rec.get('Domain')
        if not username or not email:
            logger.warning(
                "Skipping input record with missing Username and/or Email: %s"
                % user_rec)
            continue
        try:
            user = UserAction(id_type=IdentityTypes.federatedID,
                              email=username)
            user.update(email=new_email, username=new_username)
            actions[email] = user
            # if args.from_email:
            #     user.update(username=username)
            #     actions[email] = user
            # else:
            #     user.update(username=email)
            #     actions[username] = user
            conn.execute_single(user)
        except Exception as e:
            logger.error("Error with: " + username + " ||| " + 'New Email: ' +
                         new_email)

    conn.execute_queued()

    successes, failures = 0, 0
Exemplo n.º 7
0
def test_update_user_enterpriseid_username():
    user = UserAction(id_type=IdentityTypes.enterpriseID, email="*****@*****.**")
    with pytest.raises(ValueError):
        user.update(username="******")