Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-titofisto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
django-titofisto
Commits
e7bfda41
Verified
Commit
e7bfda41
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add test for mtime change invalidating token
parent
06e1c517
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
titofisto/tests.py
+15
-0
15 additions, 0 deletions
titofisto/tests.py
with
15 additions
and
0 deletions
titofisto/tests.py
+
15
−
0
View file @
e7bfda41
from
datetime
import
datetime
,
timedelta
from
io
import
BytesIO
from
pathlib
import
Path
from
unittest
import
TestCase
from
freezegun
import
freeze_time
...
...
@@ -125,3 +126,17 @@ class TitofistoTestCase(TestCase):
res
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
res
.
status_code
,
404
)
def
test_get_after_mtime_change
(
self
):
"""
A file can not be retrieved with the same token after its mtime changes
"""
now
=
datetime
.
now
()
token
,
ts
=
self
.
storage
.
get_token
(
self
.
test_file_1_name
,
now
.
strftime
(
"
%s
"
))
url
=
(
f
"
{
settings
.
MEDIA_URL
}{
self
.
test_file_1_name
}
?
"
f
"
{
self
.
param_prefix
}
token=
{
token
}
&
"
f
"
{
self
.
param_prefix
}
ts=
{
ts
}
"
)
with
freeze_time
(
now
+
timedelta
(
seconds
=
10
)):
Path
(
self
.
storage
.
path
(
self
.
test_file_1_name
)).
touch
()
res
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
res
.
status_code
,
404
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment