Commit 692c9c1f authored by Nigel Kukard's avatar Nigel Kukard

Added FUP state to mod_feature_user_stats

parent eb648bef
...@@ -147,6 +147,22 @@ sub updateUserStats ...@@ -147,6 +147,22 @@ sub updateUserStats
return MOD_RES_SKIP; return MOD_RES_SKIP;
} }
} }
# Set user FUP state
my $fupState = $user->{'AttributeConditionalVariables'}->{"SMRadius_FUP"};
if (defined($fupState)) {
$fupState = $fupState->[0];
} else {
$fupState = "-1";
}
$res = $user->{'_UserDB'}->{'Users_data_set'}($server,$user,
'mod_feature_user_stats','FUPState',
$fupState
);
if (!defined($res)) {
$server->log(LOG_ERR,"[MOD_USERS_DATA] Failed to store FUP state for user '".$user->{'Username'}."'");
return MOD_RES_SKIP;
}
} }
return MOD_RES_ACK; return MOD_RES_ACK;
......
...@@ -877,6 +877,12 @@ if ($child = fork()) { ...@@ -877,6 +877,12 @@ if ($child = fork()) {
is($res->{'listen'}->{'response'}->{'vattributes'}->{'14988'}->{'Mikrotik-Rate-Limit'}->[0],"1k/1m","Check that the vendor attribute". is($res->{'listen'}->{'response'}->{'vattributes'}->{'14988'}->{'Mikrotik-Rate-Limit'}->[0],"1k/1m","Check that the vendor attribute".
"'14988:Mikrotik-Rate-Limit' is returned on the negative side of the IF"); "'14988:Mikrotik-Rate-Limit' is returned on the negative side of the IF");
testDBResults("Check FUP state was added to the user stats table as 0",'users_data',
{'UserID' => $user5_ID, 'Name' => "FUPState"},
{'Value' => 0},
1, # Disable order
);
# #
# Check that if we send an accounting ALIVE with a usage amount that exceeds FUP, that we trigger it # Check that if we send an accounting ALIVE with a usage amount that exceeds FUP, that we trigger it
...@@ -943,7 +949,13 @@ if ($child = fork()) { ...@@ -943,7 +949,13 @@ if ($child = fork()) {
is($res->{'listen'}->{'response'}->{'code'},"CoA-Request","Check that the packet we got back is infact a ". is($res->{'listen'}->{'response'}->{'code'},"CoA-Request","Check that the packet we got back is infact a ".
"CoA-Request"); "CoA-Request");
is($res->{'listen'}->{'response'}->{'vattributes'}->{'14988'}->{'Mikrotik-Rate-Limit'}->[0],"1638k/8m","Check that the ". is($res->{'listen'}->{'response'}->{'vattributes'}->{'14988'}->{'Mikrotik-Rate-Limit'}->[0],"1638k/8m","Check that the ".
"vendor attribute '14988:Mikrotik-Rate-Limit' is returned"); "vendor attribute '14988:Mikrotik-Rate-Limit' is returned on the success side of the FUP check");
testDBResults("Check FUP state was added to the user stats table as 1",'users_data',
{'UserID' => $user6_ID, 'Name' => "FUPState"},
{'Value' => 1},
1, # Disable order
);
# #
...@@ -1084,7 +1096,7 @@ sub testDBDelete ...@@ -1084,7 +1096,7 @@ sub testDBDelete
# Test DB select results # Test DB select results
sub testDBResults sub testDBResults
{ {
my ($name,$table,$where,$resultCheck) = @_; my ($name,$table,$where,$resultCheck,$disableOrder) = @_;
# Build column list # Build column list
...@@ -1101,20 +1113,27 @@ sub testDBResults ...@@ -1101,20 +1113,27 @@ sub testDBResults
} }
my $whereLines_str = join(',',@whereLines); my $whereLines_str = join(',',@whereLines);
# Do select # Check if we're not disabling ordering
my $sth = DBSelect(" my $extraSQL = "";
if (!defined($disableOrder)) {
$extraSQL = "ORDER BY ID DESC";
}
my $sqlQuery = "
SELECT SELECT
$columnList_str $columnList_str
FROM FROM
$table $table
WHERE WHERE
$whereLines_str $whereLines_str
ORDER BY $extraSQL
ID DESC ";
",@whereData);
# Do select
my $sth = DBSelect($sqlQuery,@whereData);
# Make sure we got no error # Make sure we got no error
is(AWITPT::DB::DBLayer::error(),"","Errors on DBSelect: $name"); is(AWITPT::DB::DBLayer::error(),"","Errors on DBSelect ($sqlQuery interpolated with ".join(', ',$extraSQL).": $name");
# We should get one result... # We should get one result...
my $row = hashifyLCtoMC($sth->fetchrow_hashref(),keys %{$resultCheck}); my $row = hashifyLCtoMC($sth->fetchrow_hashref(),keys %{$resultCheck});
......
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