mirror of
https://github.com/timvisee/send.git
synced 2026-04-18 21:54:11 -04:00
implemented download tokens
This commit is contained in:
@@ -48,7 +48,7 @@ describe('/api/metadata', function() {
|
||||
storage.ttl.returns(Promise.resolve(123));
|
||||
const meta = {
|
||||
dlimit: 1,
|
||||
dl: 0,
|
||||
dlToken: 0,
|
||||
metadata: 'foo'
|
||||
};
|
||||
const res = response();
|
||||
|
||||
@@ -8,6 +8,7 @@ const storage = {
|
||||
function request(id) {
|
||||
return {
|
||||
params: { id },
|
||||
meta: { fxa: false },
|
||||
body: {}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('/api/password', function() {
|
||||
const res = response();
|
||||
passwordRoute(req, res);
|
||||
sinon.assert.calledWith(storage.setField, 'x', 'auth', 'z');
|
||||
sinon.assert.calledWith(storage.setField, 'x', 'pwd', true);
|
||||
sinon.assert.calledWith(storage.setField, 'x', 'pwd', 1);
|
||||
sinon.assert.calledWith(res.sendStatus, 200);
|
||||
});
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ const config = {
|
||||
default_expire_seconds: 20,
|
||||
expire_times_seconds: [10, 20, 30],
|
||||
env: 'development',
|
||||
redis_host: 'localhost'
|
||||
redis_host: 'mock'
|
||||
};
|
||||
|
||||
const storage = proxyquire('../../server/storage', {
|
||||
@@ -54,7 +54,7 @@ describe('Storage', function() {
|
||||
|
||||
describe('get', function() {
|
||||
it('returns a stream', async function() {
|
||||
const s = await storage.get('x');
|
||||
const { stream: s } = await storage.get('x');
|
||||
assert.equal(s, stream);
|
||||
});
|
||||
});
|
||||
@@ -123,9 +123,11 @@ describe('Storage', function() {
|
||||
describe('metadata', function() {
|
||||
it('returns all metadata fields', async function() {
|
||||
const m = {
|
||||
pwd: true,
|
||||
id: 'a1',
|
||||
pwd: 0,
|
||||
dl: 1,
|
||||
dlimit: 1,
|
||||
fxa: 1,
|
||||
auth: 'foo',
|
||||
metadata: 'bar',
|
||||
nonce: 'baz',
|
||||
@@ -133,12 +135,18 @@ describe('Storage', function() {
|
||||
};
|
||||
await storage.set('x', null, m);
|
||||
const meta = await storage.metadata('x');
|
||||
assert.deepEqual(meta, {
|
||||
...m,
|
||||
dead: false,
|
||||
flagged: false,
|
||||
key: undefined
|
||||
});
|
||||
assert.deepEqual(
|
||||
{ ...meta, storage: 'excluded' },
|
||||
{
|
||||
...m,
|
||||
dead: false,
|
||||
flagged: false,
|
||||
dlToken: 0,
|
||||
fxa: true,
|
||||
pwd: false,
|
||||
storage: 'excluded'
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,12 +2,13 @@ import assert from 'assert';
|
||||
import Archive from '../../../app/archive';
|
||||
import FileSender from '../../../app/fileSender';
|
||||
import FileReceiver from '../../../app/fileReceiver';
|
||||
import storage from '../../../app/storage';
|
||||
|
||||
const headless = /Headless/.test(navigator.userAgent);
|
||||
// TODO: save on headless doesn't work as it used to since it now
|
||||
// follows a link instead of fetch. Maybe there's a way to make it
|
||||
// work? For now always set noSave.
|
||||
const options = { noSave: true || !headless, stream: true }; // only run the saveFile code if headless
|
||||
const options = { noSave: true || !headless, stream: true, storage }; // only run the saveFile code if headless
|
||||
|
||||
// FileSender uses a File in real life but a Blob works for testing
|
||||
const blob = new Blob([new ArrayBuffer(1024 * 128)], { type: 'text/plain' });
|
||||
|
||||
Reference in New Issue
Block a user