Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vidéos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
TeDomum
Vidéos
Commits
a130f33c
Unverified
Commit
a130f33c
authored
6 years ago
by
Chocobozzz
Browse files
Options
Downloads
Patches
Plain Diff
Add AP fetch tests
parent
e5cb43e0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/tests/api/activitypub/fetch.ts
+86
-0
86 additions, 0 deletions
server/tests/api/activitypub/fetch.ts
server/tests/api/activitypub/index.ts
+1
-0
1 addition, 0 deletions
server/tests/api/activitypub/index.ts
server/tests/utils/miscs/sql.ts
+9
-0
9 additions, 0 deletions
server/tests/utils/miscs/sql.ts
with
96 additions
and
0 deletions
server/tests/api/activitypub/fetch.ts
0 → 100644
+
86
−
0
View file @
a130f33c
/* tslint:disable:no-unused-expression */
import
'
mocha
'
import
{
createUser
,
doubleFollow
,
flushAndRunMultipleServers
,
flushTests
,
getVideosListSort
,
killallServers
,
ServerInfo
,
setAccessTokensToServers
,
uploadVideo
,
userLogin
}
from
'
../../utils
'
import
*
as
chai
from
'
chai
'
import
{
setActorField
,
setVideoField
}
from
'
../../utils/miscs/sql
'
import
{
waitJobs
}
from
'
../../utils/server/jobs
'
import
{
Video
}
from
'
../../../../shared/models/videos
'
const
expect
=
chai
.
expect
describe
(
'
Test ActivityPub fetcher
'
,
function
()
{
let
servers
:
ServerInfo
[]
// ---------------------------------------------------------------
before
(
async
function
()
{
this
.
timeout
(
60000
)
servers
=
await
flushAndRunMultipleServers
(
3
)
// Get the access tokens
await
setAccessTokensToServers
(
servers
)
const
user
=
{
username
:
'
user1
'
,
password
:
'
password
'
}
for
(
const
server
of
servers
)
{
await
createUser
(
server
.
url
,
server
.
accessToken
,
user
.
username
,
user
.
password
)
}
const
userAccessToken
=
await
userLogin
(
servers
[
0
],
user
)
await
uploadVideo
(
servers
[
0
].
url
,
servers
[
0
].
accessToken
,
{
name
:
'
video root
'
})
const
res
=
await
uploadVideo
(
servers
[
0
].
url
,
servers
[
0
].
accessToken
,
{
name
:
'
bad video root
'
})
const
badVideoUUID
=
res
.
body
.
video
.
uuid
await
uploadVideo
(
servers
[
0
].
url
,
userAccessToken
,
{
name
:
'
video user
'
})
await
setActorField
(
1
,
'
http://localhost:9001/accounts/user1
'
,
'
url
'
,
'
http://localhost:9002/accounts/user1
'
)
await
setVideoField
(
1
,
badVideoUUID
,
'
url
'
,
'
http://localhost:9003/videos/watch/
'
+
badVideoUUID
)
})
it
(
'
Should add only the video with a valid actor URL
'
,
async
function
()
{
this
.
timeout
(
60000
)
await
doubleFollow
(
servers
[
0
],
servers
[
1
])
await
waitJobs
(
servers
)
{
const
res
=
await
getVideosListSort
(
servers
[
0
].
url
,
'
createdAt
'
)
expect
(
res
.
body
.
total
).
to
.
equal
(
3
)
const
data
:
Video
[]
=
res
.
body
.
data
expect
(
data
[
0
].
name
).
to
.
equal
(
'
video root
'
)
expect
(
data
[
1
].
name
).
to
.
equal
(
'
bad video root
'
)
expect
(
data
[
2
].
name
).
to
.
equal
(
'
video user
'
)
}
{
const
res
=
await
getVideosListSort
(
servers
[
1
].
url
,
'
createdAt
'
)
expect
(
res
.
body
.
total
).
to
.
equal
(
1
)
const
data
:
Video
[]
=
res
.
body
.
data
expect
(
data
[
0
].
name
).
to
.
equal
(
'
video root
'
)
}
})
after
(
async
function
()
{
killallServers
(
servers
)
// Keep the logs if the test failed
if
(
this
[
'
ok
'
])
{
await
flushTests
()
}
})
})
This diff is collapsed.
Click to expand it.
server/tests/api/activitypub/index.ts
+
1
−
0
View file @
a130f33c
import
'
./client
'
import
'
./client
'
import
'
./fetch
'
import
'
./helpers
'
import
'
./helpers
'
import
'
./security
'
import
'
./security
'
This diff is collapsed.
Click to expand it.
server/tests/utils/miscs/sql.ts
+
9
−
0
View file @
a130f33c
...
@@ -24,6 +24,15 @@ function setActorField (serverNumber: number, to: string, field: string, value:
...
@@ -24,6 +24,15 @@ function setActorField (serverNumber: number, to: string, field: string, value:
return
seq
.
query
(
`UPDATE actor SET "
${
field
}
" = '
${
value
}
' WHERE url = '
${
to
}
'`
,
options
)
return
seq
.
query
(
`UPDATE actor SET "
${
field
}
" = '
${
value
}
' WHERE url = '
${
to
}
'`
,
options
)
}
}
function
setVideoField
(
serverNumber
:
number
,
uuid
:
string
,
field
:
string
,
value
:
string
)
{
const
seq
=
getSequelize
(
serverNumber
)
const
options
=
{
type
:
Sequelize
.
QueryTypes
.
UPDATE
}
return
seq
.
query
(
`UPDATE video SET "
${
field
}
" = '
${
value
}
' WHERE uuid = '
${
uuid
}
'`
,
options
)
}
export
{
export
{
setVideoField
,
setActorField
setActorField
}
}
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