Пример #1
0
    def test_CreateSession(self):
        """
        Create a session

        Assert:
            There is a high volume of granted credits
            A static rule is installed for redirection to the captive portal
            server
            Two dynamic rules are installed for traffic from UE to captive
            portal and vice versa
        """
        msg = CreateSessionRequest()
        msg.session_id = '1234'
        msg.imsi_plmn_id = '00101'
        resp = self.servicer.CreateSession(msg, None)

        # There should be a static rule installed for the redirection
        static_rules = self._rm_whitespace(str(resp.static_rules))
        expected = self._rm_whitespace(CSR_STATIC_RULES)
        self.assertEqual(
            static_rules, expected, 'There should be one static '
            'rule installed for redirection.')

        # Credit granted should be unlimited and un-metered
        credit_limit_type = resp.credits[0].limit_type
        expected = CreditLimitType.Value("INFINITE_UNMETERED")
        self.assertEqual(
            credit_limit_type, expected, 'There should be an '
            'infinite, unmetered credit grant')
Пример #2
0
    def test_CreateSession(self):
        """
        Create a session

        Assert:
            There is a high volume of granted credits
            A static rule is installed for redirection to the captive portal
            server
            Two dynamic rules are installed for traffic from UE to captive
            portal and vice versa
        """
        msg = CreateSessionRequest()
        msg.session_id = '1234'
        msg.imsi_plmn_id = '00101'
        resp = self.servicer.CreateSession(msg, None)

        # Check the granted credits
        credits = self._rm_whitespace(str(resp.credits))
        expected = self._rm_whitespace(CSR_CREDITS)
        self.assertEqual(credits, expected, 'Expected that there is a high '
                         'volume of granted credits which will be permissive '
                         'for access to captive portal.')

        # There should be a static rule installed for the redirection
        static_rules = self._rm_whitespace(str(resp.static_rules))
        expected = self._rm_whitespace(CSR_STATIC_RULES)
        self.assertEqual(static_rules, expected, 'There should be one static '
                         'rule installed for redirection.')

        # There should be two dynamic rules:
        #   one for uplink traffic to the captive portal server from the UE
        #   one for downlink traffic from the captive portal server to the UE
        p1 = self._rm_whitespace(str(resp.dynamic_rules[0].policy_rule))
        expected = self._rm_whitespace(CSR_DYNAMIC_POLICY_1)
        self.assertEqual(p1, expected, 'There should be a dynamic rule '
                         'installed for UE traffic to the captive portal '
                         'server')

        p2 = self._rm_whitespace(str(resp.dynamic_rules[1].policy_rule))
        expected = self._rm_whitespace(CSR_DYNAMIC_POLICY_2)
        self.assertEqual(p2, expected, 'There should be a dynamic rule '
                         'installed for captive portal traffic to the UE')
Пример #3
0
    def test_CreateSession(self):
        """
        Create a session

        Assert:
            There is a high volume of granted credits
            A static rule is installed for redirection to the captive portal
            server
            Two dynamic rules are installed for traffic from UE to captive
            portal and vice versa
        """
        msg = CreateSessionRequest()
        msg.session_id = '1234'
        msg.imsi_plmn_id = '00101'
        resp = self.servicer.CreateSession(msg, None)

        # There should be a static rule installed for the redirection
        static_rules = self._rm_whitespace(str(resp.static_rules))
        expected = self._rm_whitespace(CSR_STATIC_RULES)
        self.assertEqual(
            static_rules, expected, 'There should be one static '
            'rule installed for redirection.')
Пример #4
0
    def test_CreateSession(self):
        """
        Create a session

        Assert:
            There is a high volume of granted credits
            A static rule is installed for redirection to the captive portal
            server
            Two dynamic rules are installed for traffic from UE to captive
            portal and vice versa
        """
        msg = CreateSessionRequest(
            session_id='1234',
            common_context=CommonSessionContext(
                sid=SubscriberID(id='IMSI1234', ),
                apn='apn1',
            ),
            rat_specific_context=RatSpecificContext(
                lte_context=LTESessionContext(imsi_plmn_id='00101', ), ),
        )
        resp = self.servicer.CreateSession(msg, None)

        # There should be a static rule installed for the redirection
        static_rules = self._rm_whitespace(str(resp.static_rules))
        expected = self._rm_whitespace(CSR_STATIC_RULES)
        self.assertEqual(
            static_rules, expected, 'There should be one static '
            'rule installed for redirection.')

        # Credit granted should be unlimited and un-metered
        credit_limit_type = resp.credits[0].limit_type
        expected = CreditLimitType.Value("INFINITE_UNMETERED")
        self.assertEqual(
            credit_limit_type, expected, 'There should be an '
            'infinite, unmetered credit grant')

        msg_2 = CreateSessionRequest(
            session_id='2345',
            common_context=CommonSessionContext(
                sid=SubscriberID(id='IMSI2345', ),
                apn='apn2',
            ),
            rat_specific_context=RatSpecificContext(
                lte_context=LTESessionContext(imsi_plmn_id='00101', ), ),
        )
        resp = self.servicer.CreateSession(msg_2, None)

        # There should be a static rule installed
        static_rules = self._rm_whitespace(str(resp.static_rules))
        expected = self._rm_whitespace(CSR_STATIC_RULES_2)
        self.assertEqual(static_rules, expected, 'There should be one static '
                         'rule installed.')

        # Credit granted should be unlimited and un-metered
        credit_limit_type = resp.credits[0].limit_type
        expected = CreditLimitType.Value("INFINITE_UNMETERED")
        self.assertEqual(
            credit_limit_type, expected,
            'There should be an infinite, unmetered credit grant')

        msg_3 = CreateSessionRequest(
            session_id='3456',
            common_context=CommonSessionContext(
                sid=SubscriberID(id='IMSI3456', ),
                apn='apn1',
            ),
            rat_specific_context=RatSpecificContext(
                lte_context=LTESessionContext(imsi_plmn_id='00101', ), ),
        )
        resp = self.servicer.CreateSession(msg_3, None)

        # There should be a static rule installed
        static_rules = self._rm_whitespace(str(resp.static_rules))
        expected = self._rm_whitespace(CSR_STATIC_RULES_3)
        self.assertEqual(static_rules, expected, 'There should be one static '
                         'rule installed.')

        # Credit granted should be unlimited and un-metered
        credit_limit_type = resp.credits[0].limit_type
        expected = CreditLimitType.Value("INFINITE_UNMETERED")
        self.assertEqual(
            credit_limit_type, expected,
            'There should be an infinite, unmetered credit grant')
Пример #5
0
def create_session(client, args):
    message = CreateSessionRequest()
    resp = client.CreateSession(message)
    print('Successfully got a response from CreateSession:\n', resp)