properly handle no vmod hash/blobdigest support

parent 3d30f996
...@@ -10,6 +10,12 @@ vmod_get_h_SOURCES = \ ...@@ -10,6 +10,12 @@ vmod_get_h_SOURCES = \
vmod_get_h_LDADD = -ldl vmod_get_h_LDADD = -ldl
TESTS = \
vtc/plain.vtc \
vtc/name_hash.vtc \
vtc/expires.vtc \
vtc/done.vtc
# ---------------------------------------- # ----------------------------------------
# ext vmods # ext vmods
...@@ -18,8 +24,15 @@ vmod_blob.h: vmod_get_h $(VMOD_BLOB) ...@@ -18,8 +24,15 @@ vmod_blob.h: vmod_get_h $(VMOD_BLOB)
$(builddir)/vmod_get_h blob $(VMOD_BLOB) >$@ $(builddir)/vmod_get_h blob $(VMOD_BLOB) >$@
vmod_blobdigest.h: vmod_get_h $(VMOD_BLOBDIGEST) vmod_blobdigest.h: vmod_get_h $(VMOD_BLOBDIGEST)
$(builddir)/vmod_get_h blobdigest $(VMOD_BLOBDIGEST) >$@ $(builddir)/vmod_get_h blobdigest $(VMOD_BLOBDIGEST) >$@
libvmod_tus_la_SOURCES = tus_blob.c
tus_blob.c: vmod_blob.h vmod_blobdigest.h tus_blob.c: vmod_blob.h vmod_blobdigest.h
AM_CFLAGS += -DHAVE_CHKSUM=1 TESTS += \
vtc/chksum/plain.vtc \
vtc/chksum/name_hash.vtc \
vtc/chksum/done.vtc
else
libvmod_tus_la_SOURCES = tus_blob_stub.c
endif endif
# ---------------------------------------- # ----------------------------------------
...@@ -28,11 +41,10 @@ endif ...@@ -28,11 +41,10 @@ endif
vmod_LTLIBRARIES = \ vmod_LTLIBRARIES = \
libvmod_tus.la libvmod_tus.la
libvmod_tus_la_SOURCES = \ libvmod_tus_la_SOURCES += \
tbl_hash_enum.h \ tbl_hash_enum.h \
tbl_method.h \ tbl_method.h \
tus_b64.h \ tus_b64.h \
tus_blob.c \
tus_blob.h \ tus_blob.h \
tus_checksums.h \ tus_checksums.h \
tus_concat.h \ tus_concat.h \
...@@ -79,12 +91,6 @@ AM_VTC_LOG_FLAGS = \ ...@@ -79,12 +91,6 @@ AM_VTC_LOG_FLAGS = \
-p vcl_path="$(abs_top_srcdir)/vcl:$(VARNISHAPI_VCLDIR)" \ -p vcl_path="$(abs_top_srcdir)/vcl:$(VARNISHAPI_VCLDIR)" \
-p vmod_path="$(abs_builddir)/.libs:$(vmoddir):$(VARNISHAPI_VMODDIR)" -p vmod_path="$(abs_builddir)/.libs:$(vmoddir):$(VARNISHAPI_VMODDIR)"
TESTS = \
vtc/plain.vtc \
vtc/name_hash.vtc \
vtc/expires.vtc \
vtc/done.vtc
# Documentation # Documentation
dist_doc_DATA = \ dist_doc_DATA = \
......
/*-
* Copyright 2020 UPLEX Nils Goroll Systemoptimierung
* All rights reserved.
*
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include "cache/cache.h"
#include "vsb.h"
#include "tus_blob.h"
#include "tus_checksums.h"
int
tus_chksum_init(VRT_CTX) {
(void) ctx;
return (0);
}
int
tus_chksum_fini(VRT_CTX) {
(void) ctx;
return (0);
}
/* ------------------------------------------------------------
* wrap base64
*/
VCL_BLOB
tus_b64_decode(VRT_CTX, const char *s, VCL_INT l)
{
(void) s;
(void) l;
VRT_fail(ctx, "base64 decode support not available - "
"vmod_blob support not compiled in");
return (NULL);
}
/* ------------------------------------------------------------
* enabled checksums
*/
const char *
tus_checksums(void)
{
return (NULL);
}
/* ------------------------------------------------------------
* handling of tus checksums
*/
/* tus hash names to blobdiget object */
struct vmod_blobdigest_digest *
tus_hash(const char *s, size_t l)
{
(void) s;
(void) l;
return (NULL);
}
struct tus_chksum *
tus_chksum_new(VRT_CTX, struct vmod_blobdigest_digest *d)
{
(void) ctx;
(void) d;
return (NULL);
}
struct tus_chksum *
tus_chksum_hdr(VRT_CTX, const char *hdr)
{
(void) ctx;
(void) hdr;
return (NULL);
}
void
tus_chksum_update(VRT_CTX, struct tus_chksum *c,
const void *ptr, size_t l)
{
(void) ctx;
(void) c;
(void) ptr;
(void) l;
INCOMPL();
}
VCL_BLOB
tus_chksum_final(VRT_CTX, struct tus_chksum *c)
{
(void) ctx;
(void) c;
INCOMPL();
return (NULL);
}
VCL_BOOL
tus_chksum_equal(VRT_CTX, struct tus_chksum *c)
{
(void) tus_chksum_final(ctx, c);
return (0);
}
/* tus_blob.c */
const char * tus_checksums(void);
varnishtest "test vmod-tus set done redirect"
server s1 {
rxreq
txresp
expect req.method == PUT
expect req.bodylen == 386550
} -start
varnish v1 -vcl+backend {
import blob;
import blobdigest;
import tus;
sub vcl_init {
new tmp = tus.server("http://localhost",
basedir="/tmp/tus", max = 4MB);
}
sub vcl_backend_fetch {
if (bereq.url ~ "^/id") {
set bereq.backend = s1;
} else {
return (abandon);
}
}
sub vcl_recv {
if (tmp.recv(id=req.http.id)) {
return(pass);
} else {
return(synth(4200));
}
}
sub vcl_synth {
if (resp.status == 4200) {
tmp.synth();
return (deliver);
}
}
sub vcl_deliver {
tmp.deliver();
tmp.done(req.url);
}
} -start
# dynamic file name complete post
client c1 {
txreq -method "DELETE" -url "/id" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Upload-Length: 386550" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: id" \
-nolen -hdr "Transfer-Encoding: chunked"
chunkedlen 8192
chunkedlen 4096
chunkedlen 4096
chunkedlen 16384
chunkedlen 16384
chunkedlen 16384
chunkedlen 321014
chunkedlen 0
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 4194304
expect resp.http.Upload-Offset == 386550
expect resp.http.Upload-Length == 386550
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/id"
# even for a done file, HEAD will return the correct metadata
txreq -method HEAD -url "/id" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 4194304
expect resp.http.Upload-Offset == 386550
expect resp.http.Upload-Length == 386550
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Content-Location == "http://localhost/id"
txreq -url "/id" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 301
expect resp.http.Location == "http://localhost/id"
} -run
varnishtest "test vmod-tus with name_hash"
barrier b1 cond 2
barrier b2 cond 2
server s1 {
rxreq
txresp
expect req.method == PUT
expect req.url == /c0ac9c73c39c8e396e9c18b2b5279d2df090d93b
expect req.bodylen == 100
} -start
server s2 {
rxreq
txresp
expect req.method == PUT
expect req.url == /86de97e0b0d86089c3428e2654ba7c0292849281
expect req.bodylen == 100
} -start
server s3 {
rxreq
txresp
expect req.method == PUT
expect req.url == /d641a99eb4143c2553360d1ef4a3f002e1079cb8
expect req.bodylen == 200
} -start
server s4 {
rxreq
txresp
expect req.method == PUT
expect req.url == /da39a3ee5e6b4b0d3255bfef95601890afd80709
expect req.bodylen == 0
} -start
varnish v1 -vcl+backend {
import blob;
import blobdigest;
import tus;
sub vcl_init {
new tmp = tus.server("http://localhost",
basedir="/tmp/tus_name_hash", max = 3145B, name_hash = "sha1");
}
sub vcl_backend_fetch {
if (bereq.url ~ "^/c0ac9c73c39c8e396e9c18b2b5279d2df090d93b") {
set bereq.backend = s1;
} else if (bereq.url == "/86de97e0b0d86089c3428e2654ba7c0292849281") {
set bereq.backend = s2;
} else if (bereq.url == "/d641a99eb4143c2553360d1ef4a3f002e1079cb8") {
set bereq.backend = s3;
} else if (bereq.url == "/da39a3ee5e6b4b0d3255bfef95601890afd80709") {
set bereq.backend = s4;
} else {
return (abandon);
}
}
sub vcl_recv {
if (tmp.recv(id=req.http.id)) {
return(pass);
} else {
return(synth(4200));
}
}
sub vcl_synth {
if (resp.status == 4200) {
tmp.synth();
return (deliver);
}
}
sub vcl_deliver {
tmp.deliver();
}
} -start
# dynamic file name complete post
client c1 {
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location ~ "^http://localhost/tus"
} -start
# POST/PATCH test with vtc-provided ID
client c2 {
# clean out
txreq -url "/vtc" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
# partial Upload with create
txreq -method POST \
-hdr "Upload-Metadata: filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential" \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: vtc" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-bodylen 40
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential"
expect resp.http.Location == "http://localhost/vtc"
# finish upload
txreq -method PATCH -url "/vtc" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential"
} -start
# part1
client c3 {
# clean out
txreq -url "/part1" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: part1" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-hdr "Upload-Concat: partial" \
-bodylen 40
rxresp
barrier b1 sync
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/part1"
txreq -method HEAD -url "/part1" \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
# finish upload
txreq -method PATCH -url "/part1" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
# part2
client c4 {
# clean out
txreq -url "/part2" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id: part2" \
-hdr "Upload-Defer-Length: 1" \
-hdr "Upload-Concat: partial"
rxresp
barrier b2 sync
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/part2"
txreq -method HEAD -url "/part2" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Upload-Concat == partial
# upload
txreq -method PATCH -url "/part2" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 0" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
# concat
client c5 {
# clean out
txreq -url "/d641a99eb4143c2553360d1ef4a3f002e1079cb8" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
barrier b1 sync
barrier b2 sync
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Upload-Concat: final; /part1 /part2"
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/d641a99eb4143c2553360d1ef4a3f002e1079cb8"
txreq -url /d641a99eb4143c2553360d1ef4a3f002e1079cb8 \
-method HEAD \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Upload-Concat == "final;http://localhost/part1 http://localhost/part2"
# fail patch on concat
txreq -url /d641a99eb4143c2553360d1ef4a3f002e1079cb8 \
-method PATCH \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 403
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# bad concat
client c6 {
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id:badconcat" \
-hdr "Upload-Concat: final;/foo"
rxresp
expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id:badconcat2" \
-hdr "Upload-Concat: final;"
rxresp
expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# exceeding max size
client c7 {
txreq -method POST \
-hdr "Upload-Length: 3146" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-bodylen 3146
rxresp
expect resp.status == 413
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
## XXX correct?
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# bad checksum
client c8 {
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Checksum: md5 ABCD" \
-bodylen 100
rxresp
expect resp.status == 460
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
client c9 {
# clean out
txreq -url "/empty-single" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Upload-Length: 0" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id: empty-single" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Content-Length: 0"
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location ~ "^http://localhost/empty-single"
} -start
client c1 -wait
client c2 -wait
client c3 -wait
client c4 -wait
client c5 -wait
client c6 -wait
client c7 -wait
client c8 -wait
client c9 -wait
varnishtest "test vmod-tus with ids"
barrier b1 cond 2
barrier b2 cond 2
server s1 {
rxreq
txresp
expect req.method == PUT
expect req.bodylen == 100
} -start
server s2 {
rxreq
txresp
expect req.method == PUT
expect req.url == /vtc
expect req.bodylen == 100
} -start
server s3 {
rxreq
txresp
expect req.method == PUT
expect req.url == /concat
expect req.bodylen == 200
} -start
server s4 {
rxreq
txresp
expect req.method == PUT
expect req.url == /empty-single
expect req.bodylen == 0
} -start
varnish v1 -vcl+backend {
import blob;
import blobdigest;
import tus;
sub vcl_init {
new test = tus.server("https://my.origin");
new tmp = tus.server("http://localhost",
basedir="/tmp/tus", max = 3145B);
}
sub vcl_backend_fetch {
if (bereq.url ~ "^/tus") {
set bereq.backend = s1;
} else if (bereq.url == "/vtc") {
set bereq.backend = s2;
} else if (bereq.url == "/concat") {
set bereq.backend = s3;
} else if (bereq.url == "/empty-single") {
set bereq.backend = s4;
} else {
return (abandon);
}
}
sub vcl_recv {
if (tmp.recv(id=req.http.id)) {
return(pass);
} else {
return(synth(4200));
}
}
sub meta {
set resp.http.has-filename = tmp.has_metadata("filename");
set resp.http.has-is_confidential =
tmp.has_metadata("is_confidential");
set resp.http.has-filenamee = tmp.has_metadata("filenamee");
set resp.http.has-filenam = tmp.has_metadata("filenam");
set resp.http.filename = blob.encode(IDENTITY, blob=tmp.metadata("filename"));
set resp.http.is_confidential = blob.encode(IDENTITY, blob=tmp.metadata("is_confidential"));
set resp.http.filenam = blob.encode(IDENTITY, blob=tmp.metadata("filenam"));
}
sub vcl_synth {
if (resp.status == 4200) {
call meta;
tmp.synth();
return (deliver);
}
}
sub vcl_deliver {
call meta;
tmp.deliver();
}
} -start
varnish v1 -errvcl "attempt to change basedir" {
import tus;
backend dummy None;
sub vcl_init {
new test = tus.server("http://localhost", basedir="different");
}
}
varnish v1 -errvcl "Argument 'schemeauth' missing" {
import tus;
backend dummy None;
sub vcl_init {
new test = tus.server(basedir="different");
}
}
varnish v1 -errvcl "opening basedir" {
import tus;
backend dummy None;
sub vcl_init {
new no_way = tus.server(schemeauth="http://localhost",
basedir="/dev/null/foo");
}
}
# dynamic file name complete post
client c1 {
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location ~ "^http://localhost/tus"
} -start
# POST/PATCH test with vtc-provided ID
client c2 {
# clean out
txreq -url "/vtc" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
# partial Upload with create
txreq -method POST \
-hdr "Upload-Metadata: filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential" \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: vtc" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-bodylen 40
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential"
expect resp.http.Location == "http://localhost/vtc"
expect resp.http.has-filename == true
expect resp.http.has-is_confidential == true
expect resp.http.has-filenamee == false
expect resp.http.has-filenam == false
expect resp.http.filename == "world_domination_plan.pdf"
expect resp.http.is_confidential == ""
expect resp.http.filenam == ""
# finish upload
txreq -method PATCH -url "/vtc" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential"
expect resp.http.has-filename == true
expect resp.http.has-is_confidential == true
expect resp.http.has-filenamee == false
expect resp.http.has-filenam == false
expect resp.http.filename == "world_domination_plan.pdf"
expect resp.http.is_confidential == ""
expect resp.http.filenam == ""
} -start
# part1
client c3 {
# clean out
txreq -url "/part1" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: part1" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-hdr "Upload-Concat: partial" \
-bodylen 40
rxresp
barrier b1 sync
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/part1"
txreq -method HEAD -url "/part1" \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
# finish upload
txreq -method PATCH -url "/part1" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
# part2
client c4 {
# clean out
txreq -url "/part2" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id: part2" \
-hdr "Upload-Defer-Length: 1" \
-hdr "Upload-Concat: partial"
rxresp
barrier b2 sync
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/part2"
txreq -method HEAD -url "/part2" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Upload-Concat == partial
# upload
txreq -method PATCH -url "/part2" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 0" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
# concat
client c5 {
# clean out
txreq -url "/concat" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
barrier b1 sync
barrier b2 sync
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id: concat" \
-hdr "Upload-Concat: final; /part1 /part2"
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/concat"
txreq -url /concat \
-method HEAD \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Upload-Concat == "final;http://localhost/part1 http://localhost/part2"
# fail patch on concat
txreq -url /concat \
-method PATCH \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 403
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# bad concat
client c6 {
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id:badconcat" \
-hdr "Upload-Concat: final;/foo"
rxresp
expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id:badconcat2" \
-hdr "Upload-Concat: final;"
rxresp
expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# exceeding max size
client c7 {
txreq -method POST \
-hdr "Upload-Length: 3146" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-bodylen 3146
rxresp
expect resp.status == 413
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
## XXX correct?
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# bad checksum
client c8 {
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Checksum: md5 ABCD" \
-bodylen 100
rxresp
expect resp.status == 460
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
client c9 {
# clean out
txreq -url "/empty-single" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Upload-Length: 0" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id: empty-single" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Content-Length: 0"
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location ~ "^http://localhost/empty-single"
} -start
# bad metadata fmt
client c10 {
txreq -method POST \
-hdr "Upload-Metadata: filename d29y!GRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream"
rxresp
expect resp.status == 400
txreq -method POST \
-hdr "Upload-Metadata: filename,filename" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream"
rxresp
expect resp.status == 400
} -start
client c1 -wait
client c2 -wait
client c3 -wait
client c4 -wait
client c5 -wait
client c6 -wait
client c7 -wait
client c8 -wait
client c9 -wait
client c10 -wait
...@@ -8,9 +8,6 @@ server s1 { ...@@ -8,9 +8,6 @@ server s1 {
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import blob;
import blobdigest;
import tus; import tus;
sub vcl_init { sub vcl_init {
...@@ -68,8 +65,8 @@ client c1 { ...@@ -68,8 +65,8 @@ client c1 {
expect resp.status == 201 expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 4194304 expect resp.http.Tus-Max-Size == 4194304
expect resp.http.Upload-Offset == 386550 expect resp.http.Upload-Offset == 386550
expect resp.http.Upload-Length == 386550 expect resp.http.Upload-Length == 386550
...@@ -83,8 +80,8 @@ client c1 { ...@@ -83,8 +80,8 @@ client c1 {
expect resp.status == 200 expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 4194304 expect resp.http.Tus-Max-Size == 4194304
expect resp.http.Upload-Offset == 386550 expect resp.http.Upload-Offset == 386550
expect resp.http.Upload-Length == 386550 expect resp.http.Upload-Length == 386550
......
varnishtest "test vmod-tus with name_hash" varnishtest "test vmod-tus with name_hash"
barrier b1 cond 2 varnish v1 -vcl {
barrier b2 cond 2 backend foo None;
server s1 {
rxreq
txresp
expect req.method == PUT
expect req.url == /c0ac9c73c39c8e396e9c18b2b5279d2df090d93b
expect req.bodylen == 100
} -start
server s2 {
rxreq
txresp
expect req.method == PUT
expect req.url == /86de97e0b0d86089c3428e2654ba7c0292849281
expect req.bodylen == 100
} -start
server s3 {
rxreq
txresp
expect req.method == PUT
expect req.url == /d641a99eb4143c2553360d1ef4a3f002e1079cb8
expect req.bodylen == 200
} -start
server s4 {
rxreq
txresp
expect req.method == PUT
expect req.url == /da39a3ee5e6b4b0d3255bfef95601890afd80709
expect req.bodylen == 0
} -start } -start
varnish v1 -vcl+backend { varnish v1 -errvcl "name_hash sha1 not supported" {
import blob;
import blobdigest;
import tus; import tus;
backend foo None;
sub vcl_init { sub vcl_init {
new tmp = tus.server("http://localhost", new tmp = tus.server("http://localhost",
basedir="/tmp/tus_name_hash", max = 3145B, name_hash = "sha1"); basedir="/tmp/tus_name_hash", max = 3145B, name_hash = "sha1");
} }
sub vcl_backend_fetch { }
if (bereq.url ~ "^/c0ac9c73c39c8e396e9c18b2b5279d2df090d93b") {
set bereq.backend = s1;
} else if (bereq.url == "/86de97e0b0d86089c3428e2654ba7c0292849281") {
set bereq.backend = s2;
} else if (bereq.url == "/d641a99eb4143c2553360d1ef4a3f002e1079cb8") {
set bereq.backend = s3;
} else if (bereq.url == "/da39a3ee5e6b4b0d3255bfef95601890afd80709") {
set bereq.backend = s4;
} else {
return (abandon);
}
}
sub vcl_recv {
if (tmp.recv(id=req.http.id)) {
return(pass);
} else {
return(synth(4200));
}
}
sub vcl_synth {
if (resp.status == 4200) {
tmp.synth();
return (deliver);
}
}
sub vcl_deliver {
tmp.deliver();
}
} -start
# dynamic file name complete post
client c1 {
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location ~ "^http://localhost/tus"
} -start
# POST/PATCH test with vtc-provided ID
client c2 {
# clean out
txreq -url "/vtc" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
# partial Upload with create
txreq -method POST \
-hdr "Upload-Metadata: filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential" \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: vtc" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-bodylen 40
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential"
expect resp.http.Location == "http://localhost/vtc"
# finish upload
txreq -method PATCH -url "/vtc" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential"
} -start
# part1
client c3 {
# clean out
txreq -url "/part1" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: part1" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-hdr "Upload-Concat: partial" \
-bodylen 40
rxresp
barrier b1 sync
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/part1"
txreq -method HEAD -url "/part1" \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
# finish upload
txreq -method PATCH -url "/part1" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
# part2
client c4 {
# clean out
txreq -url "/part2" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id: part2" \
-hdr "Upload-Defer-Length: 1" \
-hdr "Upload-Concat: partial"
rxresp
barrier b2 sync
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/part2"
txreq -method HEAD -url "/part2" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Upload-Concat == partial
# upload
txreq -method PATCH -url "/part2" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 0" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100
rxresp
expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
# concat
client c5 {
# clean out
txreq -url "/d641a99eb4143c2553360d1ef4a3f002e1079cb8" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
barrier b1 sync
barrier b2 sync
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Upload-Concat: final; /part1 /part2"
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/d641a99eb4143c2553360d1ef4a3f002e1079cb8"
txreq -url /d641a99eb4143c2553360d1ef4a3f002e1079cb8 \
-method HEAD \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Upload-Concat == "final;http://localhost/part1 http://localhost/part2"
# fail patch on concat
txreq -url /d641a99eb4143c2553360d1ef4a3f002e1079cb8 \
-method PATCH \
-hdr "Tus-Resumable: 1.0.0"
rxresp
expect resp.status == 403
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# bad concat
client c6 {
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id:badconcat" \
-hdr "Upload-Concat: final;/foo"
rxresp
expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
txreq -url / \
-method POST \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id:badconcat2" \
-hdr "Upload-Concat: final;"
rxresp
expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# exceeding max size
client c7 {
txreq -method POST \
-hdr "Upload-Length: 3146" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-bodylen 3146
rxresp
expect resp.status == 413
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
## XXX correct?
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef>
expect resp.http.Upload-Expires == <undef>
expect resp.http.Location == <undef>
} -start
# bad checksum
client c8 {
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Checksum: md5 ABCD" \
-bodylen 100
rxresp
expect resp.status == 460
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start
client c9 {
# clean out
txreq -url "/empty-single" \
-method DELETE \
-hdr "Content-Length: 0" \
-hdr "Tus-Resumable: 1.0.0"
rxresp
txreq -method POST \
-hdr "Upload-Length: 0" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Id: empty-single" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Content-Length: 0"
rxresp
expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 0
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location ~ "^http://localhost/empty-single"
} -start
client c1 -wait
client c2 -wait
client c3 -wait
client c4 -wait
client c5 -wait
client c6 -wait
client c7 -wait
client c8 -wait
client c9 -wait
...@@ -35,9 +35,6 @@ server s4 { ...@@ -35,9 +35,6 @@ server s4 {
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import blob;
import blobdigest;
import tus; import tus;
sub vcl_init { sub vcl_init {
...@@ -71,9 +68,6 @@ varnish v1 -vcl+backend { ...@@ -71,9 +68,6 @@ varnish v1 -vcl+backend {
tmp.has_metadata("is_confidential"); tmp.has_metadata("is_confidential");
set resp.http.has-filenamee = tmp.has_metadata("filenamee"); set resp.http.has-filenamee = tmp.has_metadata("filenamee");
set resp.http.has-filenam = tmp.has_metadata("filenam"); set resp.http.has-filenam = tmp.has_metadata("filenam");
set resp.http.filename = blob.encode(IDENTITY, blob=tmp.metadata("filename"));
set resp.http.is_confidential = blob.encode(IDENTITY, blob=tmp.metadata("is_confidential"));
set resp.http.filenam = blob.encode(IDENTITY, blob=tmp.metadata("filenam"));
} }
sub vcl_synth { sub vcl_synth {
if (resp.status == 4200) { if (resp.status == 4200) {
...@@ -125,14 +119,13 @@ client c1 { ...@@ -125,14 +119,13 @@ client c1 {
-hdr "Upload-Length: 100" \ -hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \ -hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \ -hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100 -bodylen 100
rxresp rxresp
expect resp.status == 201 expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100 expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
...@@ -156,14 +149,13 @@ client c2 { ...@@ -156,14 +149,13 @@ client c2 {
-hdr "Tus-Resumable: 1.0.0" \ -hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \ -hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: vtc" \ -hdr "Id: vtc" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-bodylen 40 -bodylen 40
rxresp rxresp
expect resp.status == 201 expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40 expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
...@@ -176,9 +168,6 @@ client c2 { ...@@ -176,9 +168,6 @@ client c2 {
expect resp.http.has-is_confidential == true expect resp.http.has-is_confidential == true
expect resp.http.has-filenamee == false expect resp.http.has-filenamee == false
expect resp.http.has-filenam == false expect resp.http.has-filenam == false
expect resp.http.filename == "world_domination_plan.pdf"
expect resp.http.is_confidential == ""
expect resp.http.filenam == ""
# finish upload # finish upload
txreq -method PATCH -url "/vtc" \ txreq -method PATCH -url "/vtc" \
...@@ -186,14 +175,13 @@ client c2 { ...@@ -186,14 +175,13 @@ client c2 {
-hdr "Content-Type: application/offset+octet-stream" \ -hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \ -hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \ -hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60 -bodylen 60
rxresp rxresp
expect resp.status == 204 expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100 expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
...@@ -205,9 +193,6 @@ client c2 { ...@@ -205,9 +193,6 @@ client c2 {
expect resp.http.has-is_confidential == true expect resp.http.has-is_confidential == true
expect resp.http.has-filenamee == false expect resp.http.has-filenamee == false
expect resp.http.has-filenam == false expect resp.http.has-filenam == false
expect resp.http.filename == "world_domination_plan.pdf"
expect resp.http.is_confidential == ""
expect resp.http.filenam == ""
} -start } -start
# part1 # part1
...@@ -224,7 +209,6 @@ client c3 { ...@@ -224,7 +209,6 @@ client c3 {
-hdr "Tus-Resumable: 1.0.0" \ -hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \ -hdr "Content-Type: application/offset+octet-stream" \
-hdr "Id: part1" \ -hdr "Id: part1" \
-hdr "Upload-Checksum: sha256 YPa+R2sYtYBoQbCv/Oy9B/MN3AJR4z5GQBHBlt+0Cu8=" \
-hdr "Upload-Concat: partial" \ -hdr "Upload-Concat: partial" \
-bodylen 40 -bodylen 40
rxresp rxresp
...@@ -234,8 +218,8 @@ client c3 { ...@@ -234,8 +218,8 @@ client c3 {
expect resp.status == 201 expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40 expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
...@@ -250,8 +234,8 @@ client c3 { ...@@ -250,8 +234,8 @@ client c3 {
expect resp.status == 200 expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 40 expect resp.http.Upload-Offset == 40
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
...@@ -263,14 +247,13 @@ client c3 { ...@@ -263,14 +247,13 @@ client c3 {
-hdr "Content-Type: application/offset+octet-stream" \ -hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \ -hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 40" \ -hdr "Upload-Offset: 40" \
-hdr "Upload-Checksum: sha256 6+WLYHJamF+3jynYkIASJo7w5z10Lt0e862/sEg/IXo=" \
-bodylen 60 -bodylen 60
rxresp rxresp
expect resp.status == 204 expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100 expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
...@@ -298,8 +281,8 @@ client c4 { ...@@ -298,8 +281,8 @@ client c4 {
expect resp.status == 201 expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1 expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef> expect resp.http.Upload-Length == <undef>
...@@ -314,8 +297,8 @@ client c4 { ...@@ -314,8 +297,8 @@ client c4 {
expect resp.status == 200 expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Defer-Length == 1 expect resp.http.Upload-Defer-Length == 1
expect resp.http.Upload-Length == <undef> expect resp.http.Upload-Length == <undef>
...@@ -329,14 +312,13 @@ client c4 { ...@@ -329,14 +312,13 @@ client c4 {
-hdr "Content-Type: application/offset+octet-stream" \ -hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Length: 100" \ -hdr "Upload-Length: 100" \
-hdr "Upload-Offset: 0" \ -hdr "Upload-Offset: 0" \
-hdr "Upload-Checksum: sha256 H98ak0Maj3gjAqfjx2KIqrwAil7CHeKsnJwyzLAXEu8=" \
-bodylen 100 -bodylen 100
rxresp rxresp
expect resp.status == 204 expect resp.status == 204
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 100 expect resp.http.Upload-Offset == 100
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
...@@ -364,8 +346,8 @@ client c5 { ...@@ -364,8 +346,8 @@ client c5 {
expect resp.status == 201 expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200 expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200 expect resp.http.Upload-Length == 200
...@@ -379,8 +361,8 @@ client c5 { ...@@ -379,8 +361,8 @@ client c5 {
expect resp.status == 200 expect resp.status == 200
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 200 expect resp.http.Upload-Offset == 200
expect resp.http.Upload-Length == 200 expect resp.http.Upload-Length == 200
...@@ -412,8 +394,8 @@ client c6 { ...@@ -412,8 +394,8 @@ client c6 {
expect resp.status == 400 expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef> expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef> expect resp.http.Upload-Length == <undef>
...@@ -429,8 +411,8 @@ client c6 { ...@@ -429,8 +411,8 @@ client c6 {
expect resp.status == 400 expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef> expect resp.http.Upload-Offset == <undef>
expect resp.http.Upload-Length == <undef> expect resp.http.Upload-Length == <undef>
...@@ -449,8 +431,8 @@ client c7 { ...@@ -449,8 +431,8 @@ client c7 {
expect resp.status == 413 expect resp.status == 413
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
## XXX correct? ## XXX correct?
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == <undef> expect resp.http.Upload-Offset == <undef>
...@@ -459,7 +441,7 @@ client c7 { ...@@ -459,7 +441,7 @@ client c7 {
expect resp.http.Location == <undef> expect resp.http.Location == <undef>
} -start } -start
# bad checksum # checksum despite not supported
client c8 { client c8 {
txreq -method POST \ txreq -method POST \
-hdr "Upload-Length: 100" \ -hdr "Upload-Length: 100" \
...@@ -468,16 +450,7 @@ client c8 { ...@@ -468,16 +450,7 @@ client c8 {
-hdr "Upload-Checksum: md5 ABCD" \ -hdr "Upload-Checksum: md5 ABCD" \
-bodylen 100 -bodylen 100
rxresp rxresp
expect resp.status == 460 expect resp.status == 400
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512"
expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$"
} -start } -start
client c9 { client c9 {
...@@ -498,8 +471,8 @@ client c9 { ...@@ -498,8 +471,8 @@ client c9 {
expect resp.status == 201 expect resp.status == 201
expect resp.http.Tus-Resumable == "1.0.0" expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0" expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation,checksum" expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == "crc32,icrc32,md5,rs,sha1,sha224,sha256,sha384,sha3_224,sha3_256,sha3_384,sha3_512,sha512" expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145 expect resp.http.Tus-Max-Size == 3145
expect resp.http.Upload-Offset == 0 expect resp.http.Upload-Offset == 0
expect resp.http.Upload-Length == 0 expect resp.http.Upload-Length == 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment