Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Téo GODDET
lemonldap-ng
Commits
5f7981e2
Commit
5f7981e2
authored
Feb 16, 2021
by
Christophe Maudoux
🐛
Browse files
Improve error message & unit test (#2458)
parent
1757cf53
Changes
20
Hide whitespace changes
Inline
Side-by-side
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/StatusConstants.pm
View file @
5f7981e2
...
...
@@ -21,6 +21,7 @@ sub portalConsts {
'
102
'
=>
'
PE_UPGRADESESSION
',
'
103
'
=>
'
PE_NO_SECOND_FACTORS
',
'
104
'
=>
'
PE_BAD_DEVOPS_FILE
',
'
105
'
=>
'
PE_FILENOTFOUND
',
'
2
'
=>
'
PE_FORMEMPTY
',
'
20
'
=>
'
PE_NO_PASSWORD_BE
',
'
21
'
=>
'
PE_PP_ACCOUNT_LOCKED
',
...
...
lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/PortalConstants.pm
View file @
5f7981e2
...
...
@@ -112,7 +112,8 @@ sub portalConstants {
PE_PP_NOT_ALLOWED_CHARACTERS
=>
101
,
PE_UPGRADESESSION
=>
102
,
PE_NO_SECOND_FACTORS
=>
103
,
PE_BAD_DEVOPS_FILE
=>
104
PE_BAD_DEVOPS_FILE
=>
104
,
PE_FILENOTFOUND
=>
105
};
}
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Constants.pm
View file @
5f7981e2
...
...
@@ -109,6 +109,7 @@ use constant {
PE_UPGRADESESSION
=>
102
,
PE_NO_SECOND_FACTORS
=>
103
,
PE_BAD_DEVOPS_FILE
=>
104
,
PE_FILENOTFOUND
=>
105
,
};
sub
portalConsts
{
...
...
@@ -126,6 +127,7 @@ sub portalConsts {
'
102
'
=>
'
PE_UPGRADESESSION
',
'
103
'
=>
'
PE_NO_SECOND_FACTORS
',
'
104
'
=>
'
PE_BAD_DEVOPS_FILE
',
'
105
'
=>
'
PE_FILENOTFOUND
',
'
2
'
=>
'
PE_FORMEMPTY
',
'
20
'
=>
'
PE_NO_PASSWORD_BE
',
'
21
'
=>
'
PE_PP_ACCOUNT_LOCKED
',
...
...
@@ -322,7 +324,8 @@ our @EXPORT_OK = (
'
PE_PP_NOT_ALLOWED_CHARACTERS
',
'
PE_UPGRADESESSION
',
'
PE_NO_SECOND_FACTORS
',
'
PE_BAD_DEVOPS_FILE
'
'
PE_BAD_DEVOPS_FILE
',
'
PE_FILENOTFOUND
'
);
our
%EXPORT_TAGS
=
(
'
all
'
=>
[
@EXPORT_OK
,
'
import
'
],
);
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/CheckDevOps.pm
View file @
5f7981e2
...
...
@@ -10,6 +10,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
PE_BADURL
PE_NOTOKEN
PE_TOKENEXPIRED
PE_FILENOTFOUND
PE_BAD_DEVOPS_FILE
)
;
...
...
@@ -133,21 +134,33 @@ sub run {
$url
=
"
$proto$vhost
/rules.json
";
my
$response
=
$self
->
ua
->
get
(
$url
,
'
Accept
'
=>
'
application/json
'
);
$self
->
logger
->
debug
(
"
Message
/Code
from
$url
:
"
.
$response
->
{
_
msg
}
.
'
/
'
.
$response
->
{
_
rc
}
);
$self
->
logger
->
debug
(
"
Code/
Message from
$url
:
"
.
$response
->
{
_
rc
}
.
'
/
'
.
$response
->
{
_
msg
}
);
$self
->
logger
->
debug
(
"
Content from
$url
:
"
.
$response
->
{
_content
}
);
$json
=
eval
{
from_json
(
$response
->
{
_content
}
)
};
"
Content from
$url
:
"
.
$response
->
{
_content
}
)
if
$response
->
{
_content
};
if
(
$@
)
{
if
(
$response
->
{
_rc
}
==
200
)
{
$json
=
eval
{
from_json
(
$response
->
{
_content
}
)
};
if
(
$@
)
{
# Prepare form params
$msg
=
'
PE
'
.
PE_BAD_DEVOPS_FILE
;
$alert
=
'
alert-danger
';
$json
=
'';
$self
->
userLogger
->
error
(
"
CheckDevOps: bad 'rules.json' file retrieved from
$url
($@)
"
);
}
}
else
{
# Prepare form params
$msg
=
'
PE
'
.
PE_
BAD_DEVOPS_FILE
;
$msg
=
'
PE
'
.
PE_
FILENOTFOUND
;
$alert
=
'
alert-danger
';
$json
=
'';
$self
->
userLogger
->
error
(
"
CheckDevOps:
b
ad 'rules.json' file
retrieved
from
$url
($@)
"
"
CheckDevOps:
Unable to downlo
ad 'rules.json' file from
$url
"
);
}
}
...
...
@@ -157,7 +170,7 @@ sub run {
$msg
=
'
PE
'
.
PE_BADURL
;
$alert
=
'
alert-danger
';
$json
=
'';
$self
->
userLogger
->
error
('
CheckDevOps: bad
URL
provided
');
$self
->
userLogger
->
error
('
CheckDevOps: bad provided
URL
');
}
}
unless
(
$json
||
$msg
)
{
...
...
@@ -185,7 +198,7 @@ sub run {
delete
$json
->
{
headers
}
->
{
$_
};
my
$user
=
$req
->
userData
->
{
$self
->
conf
->
{
whatToTrace
}
};
$self
->
userLogger
->
warn
(
"
CheckDevOps:
$user
tried to retrieve hidden attribute
$v
"
"
CheckDevOps:
$user
tried to retrieve hidden attribute
'
$v
'
"
);
}
}
...
...
lemonldap-ng-portal/site/htdocs/static/languages/ar.json
View file @
5f7981e2
...
...
@@ -94,8 +94,9 @@
"PE101"
:
"Password contains not allowed characters"
,
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"قبول"
,
"accessDenied"
:
"ليس لديك إذن بالدخول لهذا التطبيق"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/de.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"Dieser Dienst benötigt Zwei-Faktor-Authentifizierung. Bitte legen Sie ein Gerät an und gehen dann zum Portal zurück."
,
"accept"
:
"Akzeptieren"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/en.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"Accept"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/es.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"Este servicio necesita la autenticación de dos factores. Registre un dispositivo ahora, luego reingrese al portal."
,
"accept"
:
"Aceptar"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/fi.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"Hyväksy"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/fr.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Mise à niveau de la session"
,
"PE103"
:
"Aucun second facteur disponible pour votre compte"
,
"PE104"
:
"Fichier DevOps mal formaté"
,
"PE105"
:
"Fichier inexistant"
,
"2FDeviceNotFound"
:
"Second facteur non trouvé"
,
"2fRegRequired"
:
"Ce service requiert une authentification à deux facteurs. Enregistrez un équipement ici et retournez au portail."
,
"accept"
:
"Accepter"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/it.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"Questo servizio richiede un'autenticazione a doppio fattore. Registrare un dispositivo ora, quindi tornare al portale."
,
"accept"
:
"Accetta"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/nl.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"Accept"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/pl.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Sesja musi zostać zaktualizowana"
,
"PE103"
:
"Na Twoim koncie nie ma dostępnych drugich czynników"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"Nie znaleziono urządzenia 2F"
,
"2fRegRequired"
:
"Ta usługa wymaga podwójnego uwierzytelnienia. Zarejestruj urządzenie 2ndFA teraz, a następnie wróć do portalu."
,
"accept"
:
"Akceptuj"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/pt.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"Accept"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/ro.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"Accept"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/tr.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Oturum yükseltilmeli"
,
"PE103"
:
"Hesabınız için ikinci faktör kullanılabilir değil"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F cihazı bulunamadı"
,
"2fRegRequired"
:
"Bu servis iki adımlı kimlik doğrulama gerektiriyor. Şimdi bir cihaz ekleyin ve ardından portala geri dönün"
,
"accept"
:
"Kabul Et"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/vi.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"Chấp nhận"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/zh.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"Session must be upgraded"
,
"PE103"
:
"No second factors available for your account"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"2F device not found"
,
"2fRegRequired"
:
"This service requires a double factor authentication. Register a device now, then go back to the portal."
,
"accept"
:
"Accept 方法"
,
...
...
lemonldap-ng-portal/site/htdocs/static/languages/zh_TW.json
View file @
5f7981e2
...
...
@@ -95,6 +95,7 @@
"PE102"
:
"工作階段必須升級"
,
"PE103"
:
"您的帳號沒有可用的第二因素"
,
"PE104"
:
"Bad DevOps handler file"
,
"PE105"
:
"File not found"
,
"2FDeviceNotFound"
:
"找不到雙因素驗證裝置"
,
"2fRegRequired"
:
"此服務需要雙因素驗證。請先註冊裝置,然後在回到首頁。"
,
"accept"
:
"接受"
,
...
...
lemonldap-ng-portal/t/56-CheckDevOps-with-Download.t
View file @
5f7981e2
...
...
@@ -25,7 +25,7 @@ my $file = '{
}
';
my
$client
=
LLNG::Manager::
Test
->
new
(
{
ini
=>
{
logLevel
=>
'
error
',
logLevel
=>
'
debug
',
authentication
=>
'
Demo
',
userDB
=>
'
Same
',
requireToken
=>
0
,
...
...
@@ -123,6 +123,26 @@ count(13);
(
$host
,
$url
,
$query
)
=
expectForm
(
$res
,
undef
,
'
/checkdevops
',
'
checkDevOpsFile
'
);
# Fail to download file
# ---------------------
$query
=
'
url=http://testfail.example.com
';
ok
(
$res
=
$client
->
_post
(
'
/checkdevops
',
IO::
String
->
new
(
$query
),
cookie
=>
"
lemonldap=
$id
",
length
=>
length
(
$query
),
),
'
POST checkdevops with url
'
);
ok
(
$res
=
eval
{
from_json
(
$res
->
[
2
]
->
[
0
]
)
},
'
Response is JSON
'
)
or
print
STDERR
"
$@
\n
"
.
Dumper
(
$res
);
ok
(
$res
->
{
ALERTE
}
eq
'
alert-danger
',
'
alert-danger found
'
)
or
print
STDERR
Dumper
(
$res
);
ok
(
$res
->
{
MSG
}
eq
'
PE105
',
'
PE105
'
)
or
print
STDERR
Dumper
(
$res
);
count
(
4
);
# Download file
# -------------
$query
=
'
url=http://test3.example.com
';
...
...
@@ -174,9 +194,16 @@ sub LWP::UserAgent::request {
"Name": "$cn"
}
}
';
$httpResp
=
HTTP::
Response
->
new
(
200
,
'
OK
'
);
$httpResp
->
header
(
'
Content-Type
',
'
application/json
'
);
$httpResp
->
header
(
'
Content-Length
',
length
(
$s
)
);
$httpResp
->
content
(
$s
);
if
(
$req
->
{
_uri
}
=~
/testfail\.example\.com/
)
{
$httpResp
=
HTTP::
Response
->
new
(
404
,
'
NOT FOUND
'
);
$httpResp
->
header
(
'
Content-Length
',
0
);
}
else
{
$httpResp
=
HTTP::
Response
->
new
(
200
,
'
OK
'
);
$httpResp
->
header
(
'
Content-Length
',
length
(
$s
)
);
$httpResp
->
header
(
'
Content-Type
',
'
application/json
'
);
$httpResp
->
content
(
$s
);
}
return
$httpResp
;
}
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