import 'mocha'
import { omit } from 'lodash'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { HttpStatusCode, VideoPrivacy } from '@shared/models'
import {
- buildAbsoluteFixturePath,
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
- FIXTURE_URLS,
makeGetRequest,
makePostBodyRequest,
makeUploadRequest,
PeerTubeServer,
setAccessTokensToServers
-} from '@shared/extra-utils'
-import { HttpStatusCode, VideoPrivacy } from '@shared/models'
+} from '@shared/server-commands'
describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
+ it('Should fail with localhost', async function () {
+ const fields = { ...baseCorrectParams, targetUrl: 'http://localhost:8000' }
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with a private IP target urls', async function () {
+ const targetUrls = [
+ 'http://127.0.0.1:8000',
+ 'http://127.0.0.1',
+ 'http://127.0.0.1/hello',
+ 'https://192.168.1.42',
+ 'http://192.168.1.42'
+ ]
+
+ for (const targetUrl of targetUrls) {
+ const fields = { ...baseCorrectParams, targetUrl }
+
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: server.accessToken,
+ fields,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ }
+ })
+
it('Should fail with a long name', async function () {
const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }