Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
smradius
smradius
Commits
692c9c1f
Commit
692c9c1f
authored
May 16, 2019
by
Nigel Kukard
Browse files
Added FUP state to mod_feature_user_stats
parent
eb648bef
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/smradius/modules/features/mod_feature_user_stats.pm
View file @
692c9c1f
...
...
@@ -147,6 +147,22 @@ sub updateUserStats
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
;
...
...
t/200-dbtests.t
View file @
692c9c1f
...
...
@@ -877,6 +877,12 @@ if ($child = fork()) {
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
");
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
...
...
@@ -943,7 +949,13 @@ if ($child = fork()) {
is
(
$res
->
{'
listen
'}
->
{'
response
'}
->
{'
code
'},"
CoA-Request
","
Check that the packet we got back is infact a
"
.
"
CoA-Request
");
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
# Test DB select results
sub
testDBResults
{
my
(
$name
,
$table
,
$where
,
$resultCheck
)
=
@_
;
my
(
$name
,
$table
,
$where
,
$resultCheck
,
$disableOrder
)
=
@_
;
# Build column list
...
...
@@ -1101,20 +1113,27 @@ sub testDBResults
}
my
$whereLines_str
=
join
('
,
',
@whereLines
);
# Do select
my
$sth
=
DBSelect
("
# Check if we're not disabling ordering
my
$extraSQL
=
"";
if
(
!
defined
(
$disableOrder
))
{
$extraSQL
=
"
ORDER BY ID DESC
";
}
my
$sqlQuery
=
"
SELECT
$columnList_str
FROM
$table
WHERE
$whereLines_str
ORDER BY
ID DESC
",
@whereData
);
$extraSQL
";
# Do select
my
$sth
=
DBSelect
(
$sqlQuery
,
@whereData
);
# 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...
my
$row
=
hashifyLCtoMC
(
$sth
->
fetchrow_hashref
(),
keys
%
{
$resultCheck
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment