示例#1
0
 def _init_user( self, roles ):
     self.testuser = misc_functions.create_new_user( username=self.test_username,\
                                                 password=self.test_password,\
                                                 #email = self.test_email,\
                                                 org_id = self.org_id,\
                                                 #org_password = self.org_password,\
                                                 roles = roles )
示例#2
0
 def test_new_users_1(self):
     "Create a bunch of new users in an org"
     org_id = misc_functions.create_new_org()
     for i in range(10):
         u = misc_functions.create_new_user(org_id=org_id)
         self._verify_new_user(u)
         self.assertEqual(org_id, u.contact['org_id'])
示例#3
0
 def _init_user(self, roles):
     self.testuser = misc_functions.create_new_user( username=self.test_username,\
                                                 password=self.test_password,\
                                                 #email = self.test_email,\
                                                 org_id = self.org_id,\
                                                 #org_password = self.org_password,\
                                                 roles = roles )
示例#4
0
 def test_new_users_1(self):
     "Create a bunch of new users in an org"
     org_id = misc_functions.create_new_org()
     for i in range(10):
         u = misc_functions.create_new_user(org_id=org_id)
         self._verify_new_user(u)
         self.assertEqual(org_id, u.contact['org_id'])
示例#5
0
 def test_disabled_users_are_listed(self):
     "Create a user, disable it and check if it is listed"
     u = misc_functions.create_new_user()
     self._verify_new_user(u)
     username = u.contact['login']
     uid = u.getid()
     h = rhnSQL.prepare("""
     INSERT INTO rhnwebcontactchangelog
        (id, web_contact_id, change_state_id)
     VALUES
        (5555, :user_id, 2)
     """)
     h.execute(user_id=uid)
     self.assertNotEqual(rhnUser.search(username), None)
示例#6
0
 def test_disabled_users_are_listed(self):
     "Create a user, disable it and check if it is listed"
     u = misc_functions.create_new_user()
     self._verify_new_user(u)
     username = u.contact['login']
     uid = u.getid()
     h = rhnSQL.prepare("""
     INSERT INTO rhnwebcontactchangelog
        (id, web_contact_id, change_state_id)
     VALUES
        (5555, :user_id, 2)
     """)
     h.execute(user_id=uid)
     self.assertNotEqual(rhnUser.search(username), None)
    def test_new_activation_key_1(self):
        org_id = misc_functions.create_new_org()
        u = misc_functions.create_new_user(org_id=org_id)

        groups = []
        for i in range(3):
            params = misc_functions.build_server_group_params(org_id=org_id)
            sg = misc_functions.create_server_group(params)
            groups.append(sg.get_id())
        groups.sort()

        channels = [
            'rhn-tools-rhel-2.1-as-i386', 'rhn-tools-rhel-2.1-es-i386',
            'rhn-tools-rhel-2.1-ws-i386'
        ]
        channels.sort()

        token_user_id = u.getid()
        token_org_id = org_id
        token_entitlement_level = {
            'provisioning_entitled': None,
            'enterprise_entitled': None,
        }
        token_note = "Test activation key %d" % int(time.time())

        a = misc_functions.create_activation_key(
            org_id=token_org_id,
            user_id=token_user_id,
            entitlement_level=token_entitlement_level,
            note=token_note,
            groups=groups,
            channels=channels)

        token = a.get_token()

        a = rhnActivationKey.ActivationKey()
        a.load(token)

        self.assertEqual(a.get_user_id(), token_user_id)
        self.assertEqual(a.get_org_id(), token_org_id)
        self.assertEqual(a.get_entitlement_level(), token_entitlement_level)
        self.assertEqual(a.get_note(), token_note)
        g = a.get_server_groups()
        g.sort()
        self.assertEqual(g, groups)

        g = a.get_channels()
        g.sort()
        self.assertEqual(g, channels)
    def _create_new_user(self):
        # Create new org
        org_id = misc_functions.create_new_org()

        # Grant entitlements to the org
        misc_functions.grant_entitlements(org_id, 'enterprise_entitled', 1)
        misc_functions.grant_channel_family_entitlements(org_id,
            self._channel_family, 1) 
        
        # Create new user
        u = misc_functions.create_new_user(org_id=org_id, roles=['org_admin'])
        username = u.contact['login']
        # XXX This will break on satellites where passwords are encrypted
        password = u.contact['password']
        return u
示例#9
0
    def _create_new_user(self):
        # Create new org
        org_id = misc_functions.create_new_org()
        users_unencrypted_password = "******" % time.time()

        # Grant entitlements to the org
        misc_functions.grant_channel_family_entitlements(
            org_id, "%s-%.3f" % (self._channel_family, time.time()), 1)

        # Create new user
        u = misc_functions.create_new_user(
            org_id=org_id,
            roles=['org_admin'],
            password=users_unencrypted_password,
            encrypt_password=CFG.encrypted_passwords)

        return u, users_unencrypted_password
    def test_remaining_subscriptions_1(self):
        "Test registration.remaining_subscriptions call, used by RHEL4+ clients"
        org_id = misc_functions.create_new_org()
        u = misc_functions.create_new_user(org_id=org_id)

        quantity = 15
        channel_family = self._channel_family
        arch = 'i686'
        release = '3AS'
        misc_functions.grant_channel_family_entitlements(org_id,
                                                         channel_family,
                                                         quantity)

        remaining = registration.Registration().remaining_subscriptions(u.contact['login'],
                                                                        u.contact['password'],
                                                                        arch,
                                                                        release)
        self.assertEqual(str(quantity), str(remaining))
    def test_new_activation_key_1(self):
        org_id = misc_functions.create_new_org()
        u = misc_functions.create_new_user(org_id=org_id)

        groups = []
        for i in range(3):
            params = misc_functions.build_server_group_params(org_id=org_id)
            sg = misc_functions.create_server_group(params)
            groups.append(sg.get_id())
        groups.sort()

        channels = ["rhn-tools-rhel-2.1-as-i386", "rhn-tools-rhel-2.1-es-i386", "rhn-tools-rhel-2.1-ws-i386"]
        channels.sort()

        token_user_id = u.getid()
        token_org_id = org_id
        token_entitlement_level = {"provisioning_entitled": None, "enterprise_entitled": None}
        token_note = "Test activation key %d" % int(time.time())

        a = misc_functions.create_activation_key(
            org_id=token_org_id,
            user_id=token_user_id,
            entitlement_level=token_entitlement_level,
            note=token_note,
            groups=groups,
            channels=channels,
        )

        token = a.get_token()

        a = rhnActivationKey.ActivationKey()
        a.load(token)

        self.assertEqual(a.get_user_id(), token_user_id)
        self.assertEqual(a.get_org_id(), token_org_id)
        self.assertEqual(a.get_entitlement_level(), token_entitlement_level)
        self.assertEqual(a.get_note(), token_note)
        g = a.get_server_groups()
        g.sort()
        self.assertEqual(g, groups)

        g = a.get_channels()
        g.sort()
        self.assertEqual(g, channels)
    def _create_new_user(self):
        # Create new org
        org_id = misc_functions.create_new_org()
        users_unencrypted_password = "******" % time.time()

        # Grant entitlements to the org
        misc_functions.grant_channel_family_entitlements(
            org_id,
            "%s-%.3f" % (self._channel_family, time.time()),
            1
        )

        # Create new user
        u = misc_functions.create_new_user(
            org_id=org_id,
            roles=['org_admin'],
            password=users_unencrypted_password,
            encrypt_password=CFG.encrypted_passwords
        )

        return u, users_unencrypted_password
示例#13
0
 def test_new_user_2(self):
     "Create a new user in an existing org"
     org_id = misc_functions.create_new_org()
     u = misc_functions.create_new_user(org_id=org_id)
     self._verify_new_user(u)
     self.assertEqual(org_id, u.contact['org_id'])
示例#14
0
 def test_new_user_1(self):
     "Create a new user"
     u = misc_functions.create_new_user()
     self._verify_new_user(u)
示例#15
0
 def test_new_user_2(self):
     "Create a new user in an existing org"
     org_id = misc_functions.create_new_org()
     u = misc_functions.create_new_user(org_id=org_id)
     self._verify_new_user(u)
     self.assertEqual(org_id, u.contact['org_id'])
示例#16
0
 def test_new_user_1(self):
     "Create a new user"
     u = misc_functions.create_new_user()
     self._verify_new_user(u)