Beispiel #1
0
    def setUp(self):
        # Create sqlite3 database for testing
        self._tmpfile = tempfile.TemporaryDirectory()
        store = SqliteStore(self._tmpfile.name + '/')
        op = 16 * b'\x11'
        amf = b'\x80\x00'
        self._sub_profiles = {
            'superfast':
            SubscriberDB.SubscriptionProfile(max_ul_bit_rate=100000,
                                             max_dl_bit_rate=50000)
        }
        self._default_sub_profile = SubscriberDB.SubscriptionProfile(
            max_ul_bit_rate=10000, max_dl_bit_rate=5000)

        self._processor = processor.Processor(store, self._default_sub_profile,
                                              self._sub_profiles, op, amf)

        # Add some test users
        (rand, sres, gsm_key) = _dummy_auth_tuple()
        gsm = GSMSubscription(state=GSMSubscription.ACTIVE,
                              auth_tuples=[rand + sres + gsm_key])
        lte_key = 16 * b'\x00'
        lte = LTESubscription(state=LTESubscription.ACTIVE, auth_key=lte_key)
        lte_opc = LTESubscription(state=LTESubscription.ACTIVE,
                                  auth_key=lte_key,
                                  auth_opc=Milenage.generate_opc(lte_key, op))
        lte_opc_short = LTESubscription(state=LTESubscription.ACTIVE,
                                        auth_key=lte_key,
                                        auth_opc=b'\x00')
        state = SubscriberState(lte_auth_next_seq=1)
        sub1 = SubscriberData(sid=SIDUtils.to_pb('IMSI11111'),
                              gsm=gsm,
                              lte=lte,
                              state=state,
                              sub_profile='superfast')
        sub2 = SubscriberData(
            sid=SIDUtils.to_pb('IMSI22222'),  # No auth keys
            gsm=GSMSubscription(state=GSMSubscription.ACTIVE),
            lte=LTESubscription(state=LTESubscription.ACTIVE))
        sub3 = SubscriberData(
            sid=SIDUtils.to_pb('IMSI33333'))  # No subscribtion
        sub4 = SubscriberData(sid=SIDUtils.to_pb('IMSI44444'),
                              lte=lte_opc,
                              state=state)
        sub5 = SubscriberData(sid=SIDUtils.to_pb('IMSI55555'),
                              lte=lte_opc_short,
                              state=state)
        store.add_subscriber(sub1)
        store.add_subscriber(sub2)
        store.add_subscriber(sub3)
        store.add_subscriber(sub4)
        store.add_subscriber(sub5)
Beispiel #2
0
    def setUp(self):
        # Create sqlite3 database for testing
        self._tmpfile = tempfile.TemporaryDirectory()
        store = SqliteStore(self._tmpfile.name + "/")
        op = 16 * b"\x11"
        amf = b"\x80\x00"
        sub_network = CoreNetworkType()
        self._sub_profiles = {
            "superfast":
            SubscriberDB.SubscriptionProfile(
                max_ul_bit_rate=100000,
                max_dl_bit_rate=50000,
            ),
        }
        self._default_sub_profile = SubscriberDB.SubscriptionProfile(
            max_ul_bit_rate=10000,
            max_dl_bit_rate=5000,
        )
        self._sub_network = sub_network

        self._processor = processor.Processor(
            store,
            self._default_sub_profile,
            self._sub_profiles,
            op,
            amf,
            self._sub_network,
        )

        # Add some test users
        (rand, sres, gsm_key) = _dummy_auth_tuple()
        gsm = GSMSubscription(
            state=GSMSubscription.ACTIVE,
            auth_tuples=[rand + sres + gsm_key],
        )
        lte_key = 16 * b"\x00"
        lte = LTESubscription(state=LTESubscription.ACTIVE, auth_key=lte_key)
        lte_opc = LTESubscription(
            state=LTESubscription.ACTIVE,
            auth_key=lte_key,
            auth_opc=Milenage.generate_opc(lte_key, op),
        )
        lte_opc_short = LTESubscription(
            state=LTESubscription.ACTIVE,
            auth_key=lte_key,
            auth_opc=b"\x00",
        )
        sub_network = CoreNetworkType(forbidden_network_types=[
            CoreNetworkType.NT_EPC, CoreNetworkType.NT_5GC
        ], )
        state = SubscriberState(lte_auth_next_seq=1)
        sub1 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI11111"),
            gsm=gsm,
            lte=lte,
            state=state,
            sub_profile="superfast",
        )
        sub2 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI22222"),  # No auth keys
            gsm=GSMSubscription(state=GSMSubscription.ACTIVE),
            lte=LTESubscription(state=LTESubscription.ACTIVE),
        )
        sub3 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI33333"))  # No subscription
        sub4 = SubscriberData(sid=SIDUtils.to_pb("IMSI44444"),
                              lte=lte_opc,
                              state=state)
        sub5 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI55555"),
            lte=lte_opc_short,
            state=state,
        )
        sub6 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI66666"),
            sub_network=CoreNetworkType(),
        )
        store.add_subscriber(sub1)
        store.add_subscriber(sub2)
        store.add_subscriber(sub3)
        store.add_subscriber(sub4)
        store.add_subscriber(sub5)
        store.add_subscriber(sub6)