Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
slapos
Commits
dd7081cd
Commit
dd7081cd
authored
Apr 24, 2024
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update test for rack_attack
parent
854f6248
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
5 deletions
+25
-5
software/gitlab/buildout.hash.cfg
software/gitlab/buildout.hash.cfg
+1
-1
software/gitlab/software.cfg
software/gitlab/software.cfg
+1
-0
software/gitlab/template/gitlab.yml.in
software/gitlab/template/gitlab.yml.in
+1
-1
software/gitlab/test/setup.py
software/gitlab/test/setup.py
+1
-0
software/gitlab/test/test.py
software/gitlab/test/test.py
+21
-3
No files found.
software/gitlab/buildout.hash.cfg
View file @
dd7081cd
...
...
@@ -46,7 +46,7 @@ md5sum = f21ad3ae0e96e80ca4ea3819d4e9097f
[gitlab.yml.in]
_update_hash_filename_ = template/gitlab.yml.in
md5sum =
aa22a70294cb78577588854ef8403dba
md5sum =
0618288bd77ccbc7f7e9460be230fbf8
[gitaly-config.toml.in]
_update_hash_filename_ = template/gitaly-config.toml.in
...
...
software/gitlab/software.cfg
View file @
dd7081cd
...
...
@@ -402,3 +402,4 @@ docutils = 0.16
cns.recipe.symlink = 0.2.3
plone.recipe.command = 1.1
z3c.recipe.scripts = 1.0.1
beautifulsoup4 = 4.12.3
software/gitlab/template/gitlab.yml.in
View file @
dd7081cd
...
...
@@ -566,7 +566,7 @@ production: &base
{# ICP: '{{ cfg("icp_license") }}' #}
{% endif %}
rack_attack:
rack_attack:
git_basic_auth:
# Rack Attack IP banning enabled
enabled: {{ cfg("rack_attack_enable") }}
...
...
software/gitlab/test/setup.py
View file @
dd7081cd
...
...
@@ -46,6 +46,7 @@ setup(
'erp5.util'
,
'supervisor'
,
'requests'
,
'beautifulsoup4'
],
zip_safe
=
True
,
test_suite
=
'test'
,
...
...
software/gitlab/test/test.py
View file @
dd7081cd
...
...
@@ -26,10 +26,10 @@
##############################################################################
import
os
import
logging
import
urllib
import
requests
import
functools
import
bs4
from
urllib.parse
import
urljoin
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
...
...
@@ -56,10 +56,28 @@ class TestGitlab(SlapOSInstanceTestCase):
resp
.
status_code
in
[
requests
.
codes
.
ok
,
requests
.
codes
.
found
])
def
test_rack_attack_sign_in_rate_limiting
(
self
):
session
=
requests
.
session
()
# Load the login page to get a CSRF token.
response
=
session
.
get
(
urljoin
(
self
.
backend_url
,
'users/sign_in'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
# Extract the CSRF token and param.
bsoup
=
bs4
.
BeautifulSoup
(
response
.
text
,
'html.parser'
)
csrf_param
=
bsoup
.
find
(
'meta'
,
dict
(
name
=
'csrf-param'
))[
'content'
]
csrf_token
=
bsoup
.
find
(
'meta'
,
dict
(
name
=
'csrf-token'
))[
'content'
]
request_data
=
{
'user[login]'
:
'test'
,
'user[password]'
:
'random'
,
csrf_param
:
csrf_token
}
sign_in
=
functools
.
partial
(
requests
.
post
,
urllib
.
parse
.
urljoin
(
self
.
backend_url
,
'/users/sign_in'
),
response
.
url
,
data
=
request_data
,
verify
=
False
)
for
_
in
range
(
10
):
sign_in
(
headers
=
{
'X_FORWARDED_FOR'
:
'1.2.3.4'
})
# after 10 authentication failures, this client is rate limited
...
...
Write
Preview
Markdown
is supported
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