Exemplo n.º 1
0
    def test_new_server_reactivation_token_1(self):
        "Test server re-registration"
        u, password = self._create_new_user()
        username = u.contact['login']
        os_release = "2.1AS"

        params = build_new_system_params_with_username(username=username,
                                                       password=password,
                                                       os_release="2.1AS")

        system_id = register_new_system(params)
        rhnSQL.commit()

        s1 = rhnServer.get(system_id)
        self.assertNotEqual(s1, None)

        server_id_1 = s1.getid()
        groups1 = misc_functions.fetch_server_groups(server_id_1)

        # Build a re-registration token
        base_channel = 'rhel-i386-as-3'
        entitlements = self._entitlements
        t = misc_functions.create_activation_key(
            org_id=u.contact['org_id'],
            entitlement_level=entitlements,
            user_id=u.getid(),
            channels=[base_channel],
            server_id=server_id_1,
            release=os_release)

        token = t.get_token()

        params = build_new_system_params_with_token(token=token,
                                                    os_release=os_release)
        system_id = register_new_system(params)
        rhnSQL.commit()

        s2 = rhnServer.get(system_id)
        server_id_2 = s2.getid()

        groups2 = misc_functions.fetch_server_groups(server_id_2)

        self.assertNotEqual(s2, None)
        self.assertEqual(server_id_1, server_id_2)
        # Should be subscribed to the same groups
        self.assertEqual(groups1, groups2)
    def test_new_server_reactivation_token_1(self):
        "Test server re-registration"
        u, password = self._create_new_user()
        username = u.contact['login']
        os_release = "2.1AS"

        params = build_new_system_params_with_username(username=username,
                                                       password=password, os_release="2.1AS")

        system_id = register_new_system(params)
        rhnSQL.commit()

        s1 = rhnServer.get(system_id)
        self.assertNotEqual(s1, None)

        server_id_1 = s1.getid()
        groups1 = misc_functions.fetch_server_groups(server_id_1)

        # Build a re-registration token
        base_channel = 'rhel-i386-as-3'
        entitlements = self._entitlements
        t = misc_functions.create_activation_key(org_id=u.contact['org_id'],
                                                 entitlement_level=entitlements, user_id=u.getid(),
                                                 channels=[base_channel], server_id=server_id_1, release=os_release)

        token = t.get_token()

        params = build_new_system_params_with_token(
            token=token,
            os_release=os_release
        )
        system_id = register_new_system(params)
        rhnSQL.commit()

        s2 = rhnServer.get(system_id)
        server_id_2 = s2.getid()

        groups2 = misc_functions.fetch_server_groups(server_id_2)

        self.assertNotEqual(s2, None)
        self.assertEqual(server_id_1, server_id_2)
        # Should be subscribed to the same groups
        self.assertEqual(groups1, groups2)
Exemplo n.º 3
0
    def test_new_server_multiple_tokens_1(self):
        """Test registration with multiple activation tokens
        Resulting server group is the union of all server groups from all
        tokens
        """
        u, _ = self._create_new_user()
        org_id = u.contact['org_id']
        entitlements = self._entitlements
        os_release = "2.1AS"

        t = misc_functions.create_activation_key(
            org_id=u.contact['org_id'],
            entitlement_level=entitlements,
            user_id=u.getid(),
            release=os_release)

        token1 = t.get_token()
        sg1 = t.get_server_groups()

        t = misc_functions.create_activation_key(
            org_id=u.contact['org_id'],
            entitlement_level=entitlements,
            user_id=u.getid(),
            release=os_release)

        token2 = t.get_token()
        sg2 = t.get_server_groups()

        token = token1 + ',' + token2

        params = build_new_system_params_with_token(token=token,
                                                    os_release=os_release)

        system_id = register_new_system(params)
        rhnSQL.commit()

        s = rhnServer.get(system_id)
        self.assertNotEqual(s, None)

        server_id = s.getid()
        sgs = misc_functions.fetch_server_groups(server_id)
        sgstgt = sg1 + sg2
        sgstgt.sort()

        self.assertEqual(sgs, sgstgt)
    def test_new_server_multiple_tokens_1(self):
        """Test registration with multiple activation tokens
        Resulting server group is the union of all server groups from all
        tokens
        """
        u, _ = self._create_new_user()
        org_id = u.contact['org_id']
        entitlements = self._entitlements
        os_release = "2.1AS"

        t = misc_functions.create_activation_key(org_id=u.contact['org_id'],
                                                 entitlement_level=entitlements, user_id=u.getid(), release=os_release)

        token1 = t.get_token()
        sg1 = t.get_server_groups()

        t = misc_functions.create_activation_key(org_id=u.contact['org_id'],
                                                 entitlement_level=entitlements, user_id=u.getid(), release=os_release)

        token2 = t.get_token()
        sg2 = t.get_server_groups()

        token = token1 + ',' + token2

        params = build_new_system_params_with_token(token=token,
                                                    os_release=os_release)

        system_id = register_new_system(params)
        rhnSQL.commit()

        s = rhnServer.get(system_id)
        self.assertNotEqual(s, None)

        server_id = s.getid()
        sgs = misc_functions.fetch_server_groups(server_id)
        sgstgt = sg1 + sg2
        sgstgt.sort()

        self.assertEqual(sgs, sgstgt)