Commit 0343eaeb authored by Nigel Kukard's avatar Nigel Kukard

Fixed session ID's in tests

parent 8c539166
...@@ -500,7 +500,7 @@ if ($child = fork()) { ...@@ -500,7 +500,7 @@ if ($child = fork()) {
# Test missing accounting START packet # Test missing accounting START packet
# #
my $session2_ID = 81700217; my $session2_ID = "817a0f1b";
my $session2_Timestamp = time(); my $session2_Timestamp = time();
my $session2_Timestamp_str = DateTime->from_epoch(epoch => $session2_Timestamp,time_zone => 'UTC') my $session2_Timestamp_str = DateTime->from_epoch(epoch => $session2_Timestamp,time_zone => 'UTC')
->strftime('%Y-%m-%d %H:%M:%S'); ->strftime('%Y-%m-%d %H:%M:%S');
...@@ -750,7 +750,7 @@ if ($child = fork()) { ...@@ -750,7 +750,7 @@ if ($child = fork()) {
); );
my $session3_ID = 9858240; my $session3_ID = "9c5f24a";
my $session3_Timestamp = time(); my $session3_Timestamp = time();
$res = smradius::client->run( $res = smradius::client->run(
...@@ -810,7 +810,7 @@ if ($child = fork()) { ...@@ -810,7 +810,7 @@ if ($child = fork()) {
# #
# Check that if we send an accounting ALIVE we trigger the FUP # Check that if we send an accounting ALIVE we do not trigger FUP
# #
my $user5_ID = testDBInsert("Create user 'testuser5'", my $user5_ID = testDBInsert("Create user 'testuser5'",
...@@ -838,7 +838,7 @@ if ($child = fork()) { ...@@ -838,7 +838,7 @@ if ($child = fork()) {
$user5_ID,'SMRadius-Evaluate','||+=',"SMRadius_FUP > 0 ? [14988:Mikrotik-Rate-Limit] = 1638k/8m" $user5_ID,'SMRadius-Evaluate','||+=',"SMRadius_FUP > 0 ? [14988:Mikrotik-Rate-Limit] = 1638k/8m"
); );
my $session4_ID = 9858240; my $session4_ID = "a8abc40";
my $session4_Timestamp = time() - 3600; my $session4_Timestamp = time() - 3600;
$res = smradius::client->run( $res = smradius::client->run(
...@@ -870,29 +870,61 @@ if ($child = fork()) { ...@@ -870,29 +870,61 @@ if ($child = fork()) {
'Service-Type=Framed-User', 'Service-Type=Framed-User',
); );
is(ref($res),"HASH","smradclient should return a HASH"); is(ref($res),"HASH","smradclient should return a HASH");
is($res->{'response'}->{'vattributes'},undef,"Check that the vendor attributes are not defined");
my $session4_Timestamp2 = time();
#
# Check that if we send an accounting ALIVE with a usage amount that exceeds FUP, that we trigger it
#
my $user6_ID = testDBInsert("Create user 'testuser6'",
"INSERT INTO users (UserName,Disabled) VALUES ('testuser6',0)"
);
my $user6attr1_ID = testDBInsert("Create user 'testuser6' attribute 'User-Password'",
"INSERT INTO user_attributes (UserID,Name,Operator,Value,Disabled) VALUES (?,?,?,?,0)",
$user6_ID,'User-Password','==','test456'
);
my $user6attr2_ID = testDBInsert("Create user 'testuser6' attribute 'SMRadius-FUP-Period'",
"INSERT INTO user_attributes (UserID,Name,Operator,Value,Disabled) VALUES (?,?,?,?,0)",
$user6_ID,'SMRadius-FUP-Period',':=','1'
);
my $user6attr3_ID = testDBInsert("Create user 'testuser6' attribute 'SMRadius-FUP-Traffic-Threshold'",
"INSERT INTO user_attributes (UserID,Name,Operator,Value,Disabled) VALUES (?,?,?,?,0)",
$user6_ID,'SMRadius-FUP-Traffic-Threshold',':=',800
);
# Add an attribute so we can check the FUP match results
my $user6attr4_ID = testDBInsert("Create user 'testuser6' attribute 'SMRadius-Evaluate'",
"INSERT INTO user_attributes (UserID,Name,Operator,Value,Disabled) VALUES (?,?,?,?,0)",
$user6_ID,'SMRadius-Evaluate','||+=',"SMRadius_FUP > 0 ? [14988:Mikrotik-Rate-Limit] = 1638k/8m"
);
my $session5_ID = "582dc00";
my $session5_Timestamp = time() - 3600;
$res = smradius::client->run( $res = smradius::client->run(
"--raddb","dicts", "--raddb","dicts",
"127.0.0.1", "127.0.0.1",
"acct", "acct",
"secret123", "secret123",
'User-Name=testuser5', 'User-Name=testuser6',
'NAS-IP-Address=10.0.0.1', 'NAS-IP-Address=10.0.0.1',
'Acct-Delay-Time=8', 'Acct-Delay-Time=12',
'NAS-Identifier=Test-NAS2', 'NAS-Identifier=Test-NAS2',
'Acct-Status-Type=Interim-Update', 'Acct-Status-Type=Interim-Update',
'Acct-Output-Packets=700000', 'Acct-Output-Packets=786933',
'Acct-Output-Gigawords=0', 'Acct-Output-Gigawords=0',
'Acct-Output-Octets=850000000', 'Acct-Output-Octets=808163705',
'Acct-Input-Packets=100000', 'Acct-Input-Packets=670235',
'Acct-Input-Gigawords=0', 'Acct-Input-Gigawords=0',
'Acct-Input-Octets=100000000', 'Acct-Input-Octets=202600046',
'Acct-Session-Time=1000', 'Acct-Session-Time=800',
'Event-Timestamp='.$session4_Timestamp2, 'Event-Timestamp='.$session5_Timestamp,
'Framed-IP-Address=10.0.1.1', 'Framed-IP-Address=10.0.1.1',
'Acct-Session-Id='.$session4_ID, 'Acct-Session-Id='.$session5_ID,
'NAS-Port-Id=wlan1', 'NAS-Port-Id=wlan1',
'Called-Station-Id=testservice2', 'Called-Station-Id=testservice2',
'Calling-Station-Id=00:00:0C:EE:47:BF', 'Calling-Station-Id=00:00:0C:EE:47:BF',
...@@ -902,6 +934,9 @@ if ($child = fork()) { ...@@ -902,6 +934,9 @@ if ($child = fork()) {
'Service-Type=Framed-User', 'Service-Type=Framed-User',
); );
is(ref($res),"HASH","smradclient should return a HASH"); is(ref($res),"HASH","smradclient should return a HASH");
is($res->{'response'}->{'vattributes'}->{'14988'}->{'Mikrotik-Rate-Limit'}->[0],"1638k/8m","Check that the vendor attribute".
"'14988:Mikrotik-Rate-Limit' is returned");
sleep(5); sleep(5);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment