From d22bb7bc327fddbbc1abb45b46bef811bb5316ce Mon Sep 17 00:00:00 2001 From: Christophe Maudoux Date: Fri, 20 Nov 2020 12:56:31 +0100 Subject: [PATCH] Improve unit test (#2381) --- e2e-tests/custom.pm | 2 +- lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t | 8 +++++--- lemonldap-ng-handler/t/custom.pm | 3 ++- lemonldap-ng-handler/t/lmConf-1.json | 5 +++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/e2e-tests/custom.pm b/e2e-tests/custom.pm index 90a62148c..a58794f0e 100644 --- a/e2e-tests/custom.pm +++ b/e2e-tests/custom.pm @@ -17,7 +17,7 @@ sub accessToTrace { my $params = $hash->{params}; my $session = $hash->{session}; - return "$custom alias $params->[0]_$params->[1]:$session->{groups}"; + return "$custom alias $params->[0]_$params->[1]:$session->{groups} with $session->{$params->[2]}"; } 1; diff --git a/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t b/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t index 7e3bf9a33..8bc69c962 100644 --- a/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t +++ b/lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t @@ -47,11 +47,13 @@ count(2); %h = @{ $res->[1] }; ok( $h{'Lm-Remote-Custom'} eq - 'dwho@badwolf.org alias Doctor_Who:users; timelords', +'dwho@badwolf.org alias Doctor_Who:users; timelords by using Mozilla/5.0 (X11; VAX4000; rv:43.0) Gecko/20100101 Firefox/143.0 Iceweasel/143.0.1', 'Lm-Remote-Custom is overwriten' ) - or explain( \%h, - 'Lm-Remote-Custom => "dwho@badwolf.org alias Doctor_Who:users; timelords"' ); + or explain( + \%h, +'Lm-Remote-Custom => "dwho@badwolf.org alias Doctor_Who:users; timelords by using Mozilla/5.0 (X11; VAX4000; rv:43.0) Gecko/20100101 Firefox/143.0 Iceweasel/143.0.1"' + ); count(1); # Authorized query diff --git a/lemonldap-ng-handler/t/custom.pm b/lemonldap-ng-handler/t/custom.pm index 1e455e1aa..2c000893a 100644 --- a/lemonldap-ng-handler/t/custom.pm +++ b/lemonldap-ng-handler/t/custom.pm @@ -9,7 +9,8 @@ sub accessToTrace { my $params = $hash->{params}; my $session = $hash->{session}; - return "$custom alias $params->[0]_$params->[1]:$session->{groups}"; + return +"$custom alias $params->[0]_$params->[1]:$session->{groups} by using $session->{ $params->[2] }"; } 1; diff --git a/lemonldap-ng-handler/t/lmConf-1.json b/lemonldap-ng-handler/t/lmConf-1.json index 37756dd93..b98ef751e 100644 --- a/lemonldap-ng-handler/t/lmConf-1.json +++ b/lemonldap-ng-handler/t/lmConf-1.json @@ -76,7 +76,8 @@ } }, "macros": { - "_whatToTrace": "$_auth eq 'SAML' ? \"$_user\\@$_idpConfKey\" : \"$_user\"" + "_whatToTrace": "$_auth eq 'SAML' ? \"$_user\\@$_idpConfKey\" : \"$_user\"", + "UA": "$ENV{HTTP_USER_AGENT}" }, "portal": "http://auth.example.com/", "reloadUrls": {}, @@ -86,7 +87,7 @@ "vhostAuthnLevel": 5 }, "test4.example.com": { - "vhostAccessToTrace": "My::accessToTrace, Doctor, Who" + "vhostAccessToTrace": "My::accessToTrace, Doctor, Who, UA" } }, "whatToTrace": "_whatToTrace",