mirror of
https://github.com/strapi/strapi.git
synced 2025-07-25 01:49:34 +00:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
// Helpers.
|
|
const { registerAndLogin } = require('../../../test/helpers/auth');
|
|
const { createAuthRequest } = require('../../../test/helpers/request');
|
|
|
|
let rq;
|
|
|
|
describe('Upload plugin end to end tests', () => {
|
|
beforeAll(async () => {
|
|
const token = await registerAndLogin();
|
|
rq = createAuthRequest(token);
|
|
}, 60000);
|
|
|
|
describe('GET /upload/proxy => Proxy the file', () => {
|
|
test('Return the remote URL', async () => {
|
|
const res = await rq.get('/upload/proxy', {
|
|
qs: {
|
|
url: 'https://strapi.io/',
|
|
},
|
|
});
|
|
expect(res.statusCode).toBe(200);
|
|
});
|
|
|
|
test('Accept an url with utf-8 characters', async () => {
|
|
const res = await rq.get('/upload/proxy', {
|
|
qs: {
|
|
url: 'https://strapi.io/?foo=网',
|
|
},
|
|
});
|
|
|
|
expect(res.statusCode).toBe(200);
|
|
});
|
|
|
|
test('Return 400 with an invalid url', async () => {
|
|
const res = await rq.get('/upload/proxy');
|
|
|
|
expect(res.statusCode).toBe(400);
|
|
expect(res.body).toEqual('Invalid URL');
|
|
});
|
|
});
|
|
});
|