コード例 #1
0
ファイル: tests.py プロジェクト: deone/radius-dev
    def setUp(self):
        self.start = (
            ('User-Name', '"*****@*****.**"'),
            ('Acct-Status-Type', 'Start'),
            )

        self.stop = (
            ('User-Name', '"*****@*****.**"'),
            ('Acct-Status-Type', 'Stop'),
            ('Acct-Input-Octets', '255909888'),
            ('Acct-Output-Octets', '19741696'),
            )

        self.excess_octets_stop = (
            ('User-Name', '"*****@*****.**"'),
            ('Acct-Status-Type', 'Stop'),
            ('Acct-Input-Octets', '600000000'),
            ('Acct-Output-Octets', '500000000'),
            )

        self.username = '******'
        self.password = '******'
        self.group = GroupAccount.objects.create(name='CUG', max_no_of_users=10, data_balance=1)
        self.user = User.objects.create_user(self.username, self.username, self.password)
        self.subscriber = Subscriber.objects.create(user=self.user, country='NGA', phone_number='+2348029299274')
        self.radcheck = Radcheck.objects.create(user=self.user, username=self.username,
            attribute='MD5-Password', op=':=', value=md5_password(self.password), is_logged_in=True, data_balance=1)
コード例 #2
0
ファイル: test_utils.py プロジェクト: deone/billing
 def setUp(self):
     username = '******'
     password = '******'
     user = User.objects.create_user(username, username, password)
     self.radcheck = Radcheck.objects.create(user=user,
                             username=username,
                             attribute='MD5-Password',
                             op=':=',
                             value=md5_password(password),
                             data_balance=1)
     package = Package.objects.create(package_type='Daily', volume='Unlimited', speed='1.5', price=5)
     
     """
     Note about microsecond precision
     ================================
     test_check_subscription fails when we use self.ps as returned by create.
     This ps object contains the microseconds value which 
     self.radcheck.packagesubscription_set.all()[0] does not return.
     To fix this, we are just going to create the object and select it 
     from the database to get rid of the microseconds value.
     """
     PackageSubscription.objects.create(radcheck=self.radcheck, package=package, start=timezone.now())
     self.ps = PackageSubscription.objects.get(radcheck=self.radcheck)
     self.ps.stop = compute_stop_time(self.ps.start, self.ps.package.package_type)
     self.ps.save()
コード例 #3
0
ファイル: tests.py プロジェクト: deone/radius-dev
    def setUp(self):
        self.p = (
            ('Acct-Session-Id', '"624874448299458941"'),
            ('Called-Station-Id', '"00-18-0A-F2-DE-11:Radius test"'),
            ('Calling-Station-Id', '"48-D2-24-43-A6-C1"'),
            ('Framed-IP-Address', '172.31.3.142'),
            ('NAS-Identifier', '"Cisco Meraki cloud RADIUS client"'),
            ('NAS-IP-Address', '108.161.147.120'),
            ('NAS-Port', '0'),
            ('NAS-Port-Id', '"Wireless-802.11"'),
            ('NAS-Port-Type', 'Wireless-802.11'),
            ('Service-Type', 'Login-User'),
            ('User-Name', '"*****@*****.**"'),
            ('User-Password', '"12345"'),
            # ('User-Name', '"*****@*****.**"'),
            # ('User-Password', '"12345"'),
            # ('User-Name', '"*****@*****.**"'),
            # ('User-Password', '"EYQL9B"'),
            ('Attr-26.29671.1', '0x446a756e676c65204851203032')
            )
        
        self.now = timezone.now()
        self.params = dict(self.p)
        self.username = rules.trim_value(self.params['User-Name'])
        self.password = rules.trim_value(self.params['User-Password'])

        self.user = User.objects.create_user(self.username, self.username, self.password)
        self.group = GroupAccount.objects.create(name='CUG', max_no_of_users=10)
        self.subscriber = Subscriber.objects.create(user=self.user, country='NGA', phone_number='+2348029299274', group=self.group)
        self.voucher = Radcheck.objects.create(user=self.user, username=self.username,
            attribute='MD5-Password', op=':=', value=md5_password(self.password), data_balance=1)
        self.package = Package.objects.create(package_type='Daily',
            volume='3', speed='1.5', price=4)
        self.ivoucher = InstantVoucher.objects.create(radcheck=self.voucher, package=self.package)
        self.ap = AccessPoint.objects.create(name='My AP', mac_address='00:18:0A:F2:DE:11')
コード例 #4
0
 def setUp(self):
     username = '******'
     password = '******'
     user = User.objects.create_user(username, username, password)
     self.radcheck = Radcheck.objects.create(user=user,
                                             username=username,
                                             attribute='MD5-Password',
                                             op=':=',
                                             value=md5_password(password))
     self.group = GroupAccount.objects.create(name='CUG',
                                              max_no_of_users=10)
     self.package = Package.objects.create(package_type='Daily',
                                           volume='3',
                                           speed='1.5',
                                           price=4)
     now = timezone.now()
     self.gps = GroupPackageSubscription.objects.create(
         group=self.group,
         package=self.package,
         start=now,
         stop=now + timedelta(hours=settings.PACKAGE_TYPES_HOURS_MAP[
             self.package.package_type]))
     self.ps = PackageSubscription.objects.create(
         radcheck=self.radcheck,
         package=self.package,
         start=now,
         stop=now + timedelta(hours=settings.PACKAGE_TYPES_HOURS_MAP[
             self.package.package_type]))
コード例 #5
0
ファイル: test_utils.py プロジェクト: deone/billing-v1
 def setUp(self):
     username = '******'
     password = '******'
     user = User.objects.create_user(username, username, password)
     self.radcheck = Radcheck.objects.create(user=user,
                                             username=username,
                                             attribute='MD5-Password',
                                             op=':=',
                                             value=md5_password(password),
                                             data_balance=1)
     package = Package.objects.create(package_type='Daily',
                                      volume='Unlimited',
                                      speed='1.5',
                                      price=5)
     """
     Note about microsecond precision
     ================================
     test_check_subscription fails when we use self.ps as returned by create.
     This ps object contains the microseconds value which 
     self.radcheck.packagesubscription_set.all()[0] does not return.
     To fix this, we are just going to create the object and select it 
     from the database to get rid of the microseconds value.
     """
     PackageSubscription.objects.create(radcheck=self.radcheck,
                                        package=package,
                                        start=timezone.now())
     self.ps = PackageSubscription.objects.get(radcheck=self.radcheck)
     self.ps.stop = compute_stop_time(self.ps.start,
                                      self.ps.package.package_type)
     self.ps.save()
コード例 #6
0
ファイル: tests.py プロジェクト: deone/radius-dev
 def setUp(self, *args, **kwargs):
     super(AuthorizeVoucherTestCase, self).setUp(*args, **kwargs)
     self.voucher = Radcheck.objects.create(user=None, username='******',
         attribute='MD5-Password', op=':=', value=md5_password('12345'), data_balance=1)
     self.package = Package.objects.create(package_type='Daily', volume='3', speed='1.5', price=4)
     self.iv = InstantVoucher.objects.create(radcheck=self.voucher, package=self.package)
     self.ap.status = 'PUB'
     self.ap.save()
コード例 #7
0
ファイル: tests.py プロジェクト: deone/radius-dev
    def test_voucher_password_incorrect(self):
        self.voucher.value = md5_password('00000')
        self.voucher.save()

        result = rules.authorize(self.p)
        self.assertEqual(len(result), 3)
        self.assertEqual(result[0], 0)
        self.assertEqual(result[1][0], ('Reply-Message', 'Voucher Password Incorrect'))
コード例 #8
0
 def test_get_voucher(self):
     username = '******'
     voucher = Radcheck.objects.create(user=None,
                                       username=username,
                                       attribute='MD5-Password',
                                       op=':=',
                                       value=md5_password('12345'))
     self.assertTrue(isinstance(rules.get_voucher(username), Radcheck))
     voucher.delete()
コード例 #9
0
    def test_voucher_password_incorrect(self):
        self.voucher.value = md5_password('00000')
        self.voucher.save()

        result = rules.authorize(self.p)
        self.assertEqual(len(result), 3)
        self.assertEqual(result[0], 0)
        self.assertEqual(result[1][0],
                         ('Reply-Message', 'Voucher Password Incorrect'))
コード例 #10
0
ファイル: test_admin.py プロジェクト: JannKleen/billing
 def setUp(self, *args, **kwargs):
     super(PackageSubscriptionAdminTests, self).setUp(*args, **kwargs)
     username = '******'
     password = '******'
     user = User.objects.create_user(username, username, password)
     self.radcheck = Radcheck.objects.create(user=user,
                                             username=username,
                                             attribute='MD5-Password',
                                             op=':=',
                                             value=md5_password(password))
コード例 #11
0
    def setUp(self):
        self.p = (
            ('Acct-Session-Id', '"624874448299458941"'),
            ('Called-Station-Id', '"00-18-0A-F2-DE-11:Radius test"'),
            ('Calling-Station-Id', '"48-D2-24-43-A6-C1"'),
            ('Framed-IP-Address', '172.31.3.142'),
            ('NAS-Identifier', '"Cisco Meraki cloud RADIUS client"'),
            ('NAS-IP-Address', '108.161.147.120'),
            ('NAS-Port', '0'),
            ('NAS-Port-Id', '"Wireless-802.11"'),
            ('NAS-Port-Type', 'Wireless-802.11'),
            ('Service-Type', 'Login-User'),
            ('User-Name', '"*****@*****.**"'),
            ('User-Password', '"12345"'),
            # ('User-Name', '"*****@*****.**"'),
            # ('User-Password', '"12345"'),
            # ('User-Name', '"*****@*****.**"'),
            # ('User-Password', '"EYQL9B"'),
            ('Attr-26.29671.1', '0x446a756e676c65204851203032'))

        self.now = timezone.now()
        self.params = dict(self.p)
        self.username = rules.trim_value(self.params['User-Name'])
        self.password = rules.trim_value(self.params['User-Password'])

        self.user = User.objects.create_user(self.username, self.username,
                                             self.password)
        self.group = GroupAccount.objects.create(name='CUG',
                                                 max_no_of_users=10)
        self.subscriber = Subscriber.objects.create(
            user=self.user,
            country='NGA',
            phone_number='+2348029299274',
            group=self.group)
        self.voucher = Radcheck.objects.create(user=self.user,
                                               username=self.username,
                                               attribute='MD5-Password',
                                               op=':=',
                                               value=md5_password(
                                                   self.password),
                                               data_balance=1)
        self.package = Package.objects.create(package_type='Daily',
                                              volume='3',
                                              speed='1.5',
                                              price=4)
        self.ivoucher = InstantVoucher.objects.create(radcheck=self.voucher,
                                                      package=self.package)
        self.ap = AccessPoint.objects.create(name='My AP',
                                             mac_address='00:18:0A:F2:DE:11')
コード例 #12
0
def insert_vouchers(request):
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        package_id = request.POST['package_id']

        radcheck = Radcheck.objects.create(username=username,
                                           attribute='MD5-Password',
                                           op=':=',
                                           value=md5_password(password))
        package = Package.objects.get(pk=package_id)

        InstantVoucher.objects.create(radcheck=radcheck, package=package)

    return JsonResponse({'status': 'ok'})
コード例 #13
0
ファイル: views.py プロジェクト: JannKleen/billing
def insert_vouchers(request):
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        package_id = request.POST['package_id']

        radcheck = Radcheck.objects.create(username=username,
                                    attribute='MD5-Password',
                                    op=':=',
                                    value=md5_password(password))
        package = Package.objects.get(pk=package_id)

        InstantVoucher.objects.create(radcheck=radcheck, package=package)

    return JsonResponse({'status': 'ok'})
コード例 #14
0
 def setUp(self, *args, **kwargs):
     super(AuthorizeVoucherTestCase, self).setUp(*args, **kwargs)
     self.voucher = Radcheck.objects.create(user=None,
                                            username='******',
                                            attribute='MD5-Password',
                                            op=':=',
                                            value=md5_password('12345'),
                                            data_balance=1)
     self.package = Package.objects.create(package_type='Daily',
                                           volume='3',
                                           speed='1.5',
                                           price=4)
     self.iv = InstantVoucher.objects.create(radcheck=self.voucher,
                                             package=self.package)
     self.ap.status = 'PUB'
     self.ap.save()
コード例 #15
0
 def setUp(self):
     username = '******'
     password = '******'
     user = User.objects.create_user(username, username, password)
     self.radcheck = Radcheck.objects.create(user=user,
                                             username=username,
                                             attribute='MD5-Password',
                                             op=':=',
                                             value=md5_password(password))
     package = Package.objects.create(package_type='Daily',
                                      volume='Unlimited',
                                      speed='1.5',
                                      price=5)
     self.ps = PackageSubscription.objects.create(radcheck=self.radcheck,
                                                  package=package,
                                                  start=timezone.now())
     self.ps.stop = compute_stop(self.ps.start,
                                 self.ps.package.package_type)
     self.ps.save()
コード例 #16
0
ファイル: test_models.py プロジェクト: deone/billing
 def setUp(self):
     username = '******'
     password = '******'
     user = User.objects.create_user(username, username, password)
     self.radcheck = Radcheck.objects.create(user=user,
                             username=username,
                             attribute='MD5-Password',
                             op=':=',
                             value=md5_password(password))
     self.group = GroupAccount.objects.create(name='CUG',
         max_no_of_users=10, data_balance=1)
     self.package = Package.objects.create(package_type='Daily',
         volume='3', speed='1.5', price=4)
     now = timezone.now()
     self.gps = GroupPackageSubscription.objects.create(group=self.group,
         package=self.package, start=now,
         stop=now + timedelta(hours=settings.PACKAGE_TYPES_HOURS_MAP[self.package.package_type]))
     self.ps = PackageSubscription.objects.create(
         radcheck=self.radcheck, package=self.package, start=now,
         stop=now + timedelta(hours=settings.PACKAGE_TYPES_HOURS_MAP[self.package.package_type]))
コード例 #17
0
 def setUp(self):
     username = '******'
     password = '******'
     self.user = User.objects.create_user(username, username, password)
     self.subscriber = Subscriber.objects.create(user=self.user, country='GHA', phone_number='0542751610')
     self.radcheck = Radcheck.objects.create(user=self.user,
                             username=username,
                             attribute='MD5-Password',
                             op=':=',
                             value=md5_password(password))
     self.package = Package.objects.create(package_type='Monthly', volume='Unlimited', speed='1.5', price=4)
     self.data = {'package_choice': str(self.package.pk)}
     self.packages = [(p.id, p) for p in Package.objects.all()]
     self.recharge = RechargeAndUsage.objects.create(
         radcheck=self.radcheck,
         amount=3,
         balance=3,
         action='REC',
         activity_id=20
     )
コード例 #18
0
    def setUp(self):
        self.start = (
            ('User-Name', '"*****@*****.**"'),
            ('Acct-Status-Type', 'Start'),
        )

        self.stop = (
            ('User-Name', '"*****@*****.**"'),
            ('Acct-Status-Type', 'Stop'),
            ('Acct-Input-Octets', '255909888'),
            ('Acct-Output-Octets', '19741696'),
        )

        self.excess_octets_stop = (
            ('User-Name', '"*****@*****.**"'),
            ('Acct-Status-Type', 'Stop'),
            ('Acct-Input-Octets', '600000000'),
            ('Acct-Output-Octets', '500000000'),
        )

        self.username = '******'
        self.password = '******'
        self.group = GroupAccount.objects.create(name='CUG',
                                                 max_no_of_users=10,
                                                 data_balance=1)
        self.user = User.objects.create_user(self.username, self.username,
                                             self.password)
        self.subscriber = Subscriber.objects.create(
            user=self.user, country='NGA', phone_number='+2348029299274')
        self.radcheck = Radcheck.objects.create(user=self.user,
                                                username=self.username,
                                                attribute='MD5-Password',
                                                op=':=',
                                                value=md5_password(
                                                    self.password),
                                                is_logged_in=True,
                                                data_balance=1)
コード例 #19
0
ファイル: create_users.py プロジェクト: JannKleen/billing
    return ''.join(random.choice(chars) for _ in range(size))


with open(_file, 'r') as f:
    lines = f.readlines()

for line in lines:
    first_name, last_name, email = line.split(',')
    email = email[:-1]
    password = id_generator()
    user = User.objects.create_user(email, email, password)
    user.first_name = first_name
    user.last_name = last_name
    user.save()

    group = GroupAccount.objects.get(name__exact="Koforidua Polytechnic")
    Subscriber.objects.create(group=group,
                              is_group_admin=False,
                              country='GHA',
                              email_verified=False,
                              user=user)
    Radcheck.objects.create(user=user,
                            username=email,
                            attribute='MD5-Password',
                            op=':=',
                            value=md5_password(password))

    with open('done.csv', 'a') as f:
        f.write(first_name + ',' + last_name + ',' + email + ',' + password +
                '\n')
コード例 #20
0
ファイル: rules.old.py プロジェクト: deone/radius-dev
def check_voucher_password(voucher_password, user_password):
    if md5_password(user_password) != voucher_password:
        return "VPI"
    else:
        print_info("*** - Voucher Password Correct :-) ***")
        return True
コード例 #21
0
def check_voucher_password(voucher_password, user_password):
    if md5_password(user_password) != voucher_password:
        return 'VPI'
    else:
        print_info('*** - Voucher Password Correct :-) ***')
        return True
コード例 #22
0
def check_voucher_password(voucher_password, user_password):
    if md5_password(user_password) != voucher_password:
        return 'VPI'
    else:
        return True
コード例 #23
0
ファイル: tests.py プロジェクト: deone/radius-dev
 def test_get_voucher(self):
     username = '******'
     voucher = Radcheck.objects.create(user=None, username=username,
         attribute='MD5-Password', op=':=', value=md5_password('12345'))
     self.assertTrue(isinstance(rules.get_voucher(username), Radcheck))
     voucher.delete()