### Yeet: Upload a JSON file POST http://{{host}}:{{port}}/yeet Content-Type: application/json { "some": "field" } > {% client.test("Request executed successfully", function() { client.assert(response.status === 201, "Response status is not 201"); }); client.test("Response content-type is JSON", function() { const type = response.contentType.mimeType; client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'"); }); client.test("ID values match", function() { const id = response.body['id']; client.assert(id === response.headers.valuesOf("yy-id")[0], "ID in body does not match ID in header"); }); client.test("File size is set", function() { const id = response.body['file_size_bytes']; client.assert(id > 0, "File size is invalid"); }); client.test("File SHA-256 hash is calculated correctly", function() { const hash = response.body['hashes']['sha256']; client.assert(hash === "1701b0ca1b4ebfa222e968c83ebf6175379e5b4726c2be41ba366ac2fed1725d", "File SHA-256 is invalid"); }); client.test("File MD5 hash is calculated correctly", function() { const hash = response.body['hashes']['md5']; client.assert(hash === "e26522e17d7910858ea83ad6f02b1b5f", "File MD5 is invalid"); }); // Fetch the created ID off the response and set it // as a variable for fetching it in the next step. client.global.set("file_id", response.headers.valuesOf("yy-id")[0]); // Store expected file size for later testing client.global.set("file_size", response.body['file_size_bytes']); %} ### Yoink: Get a file GET http://{{host}}:{{port}}/yoink/{{file_id}} > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); }); client.test("Request lengths are matching", function() { const expected_length = client.global.get('file_size'); client.assert(response.headers.valuesOf("content-length")[0] == expected_length, "Response length " + response.body.length + " does not match length " + expected_length + " reported in original POST response"); }); client.test("File SHA-256 hash is returned correctly", function() { const hash = response.headers.valuesOf("yy-file-sha256")[0]; client.assert(hash === '1701b0ca1b4ebfa222e968c83ebf6175379e5b4726c2be41ba366ac2fed1725d', "SHA-256 value in yy-file-sha256 header is incorrect"); client.assert(response.headers.valuesOf("etag")[0] === 'FwGwyhtOv6Ii6WjIPr9hdTeeW0cmwr5BujZqwv7Rcl0=', "SHA-256 value in ETag header is incorrect"); }); client.test("File MD5 hash is returned correctly", function() { const hash = response.headers.valuesOf("yy-file-md5")[0]; client.assert(hash === 'e26522e17d7910858ea83ad6f02b1b5f', "MD5 value in yy-file-md5 header is incorrect"); client.assert(response.headers.valuesOf("content-md5")[0] === '4mUi4X15EIWOqDrW8CsbXw==', "MD5 value in content-md5 header is incorrect"); }); %} ### Yeet: Upload a JSON file (dynamic content) POST http://{{host}}:{{port}}/yeet Content-Type: application/json { "some": "field", "ts": {{$timestamp}} } > {% client.test("Request executed successfully", function() { client.assert(response.status === 201, "Response status is not 201"); }); client.test("Response content-type is JSON", function() { const type = response.contentType.mimeType; client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'"); }); client.test("File SHA-256 hash is calculated correctly", function() { const hash = response.body['hashes']['sha256']; // We simply test that this value is different from the one in the tests above since this file contains // dynamic content. As a result, its hash must be different every time. client.assert(hash != "1701b0ca1b4ebfa222e968c83ebf6175379e5b4726c2be41ba366ac2fed1725d", "File SHA-256 is invalid"); }); client.test("File MD5 hash is calculated correctly", function() { const hash = response.body['hashes']['md5']; // We simply test that this value is different from the one in the tests above since this file contains // dynamic content. As a result, its hash must be different every time. client.assert(hash != "e26522e17d7910858ea83ad6f02b1b5f", "File MD5 is invalid"); }); %}