Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: useSignedUrl returns 501 for getObject and putObject #7 #8 #9

Merged
merged 3 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM gitpod/workspace-full

RUN echo "force image rebuild: foobar"

RUN curl -fsSL https://deno.land/x/install/install.sh | sh
RUN /home/gitpod/.deno/bin/deno completions bash > /home/gitpod/.bashrc.d/90-deno && echo 'export DENO_INSTALL="/home/gitpod/.deno"' >> /home/gitpod/.bashrc.d/90-deno && echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /home/gitpod/.bashrc.d/90-deno
21 changes: 19 additions & 2 deletions adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ export default function (root) {
* @param {StorageObject}
* @returns {Promise<Response>}
*/
function putObject({ bucket, object, stream }) {
function putObject({ bucket, object, stream, useSignedUrl }) {
if (useSignedUrl) {
return Promise.resolve(
HyperErr({
status: 501,
msg: "Not Implemented",
}),
);
}
// Create Writer
return Async.of(resolvePath(bucket, object))
.chain(create)
Expand Down Expand Up @@ -150,7 +158,16 @@ export default function (root) {
* @param {StorageInfo}
* @returns {Promise<stream>}
*/
function getObject({ bucket, object }) {
function getObject({ bucket, object, useSignedUrl }) {
if (useSignedUrl) {
return Promise.resolve(
HyperErr({
status: 501,
msg: "Not Implemented",
}),
);
}

return Async.of(resolvePath(bucket, object))
.chain((p) => open(p, { read: true, write: false }))
.bimap(
Expand Down
32 changes: 32 additions & 0 deletions adapter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ Deno.test("fs adapter put object", async () => {
});
});

Deno.test("fs adapter put object - useSignedUrl", async () => {
// setup
const bucket = v4();
const object = v4() + ".txt";
await adapter.makeBucket(bucket);

// test
const result = await adapter.putObject({
bucket,
object,
useSignedUrl: true,
}).catch((err) => err);
assert(!result.ok);
assert(result.status === 501);
});

Deno.test("fs adapter get object", async () => {
const bucket = v4();
const object = v4() + ".txt";
Expand Down Expand Up @@ -193,6 +209,22 @@ Deno.test("fs adapter get object", async () => {
});
});

Deno.test("fs adapter get object - useSignedUrl", async () => {
// setup
const bucket = v4();
const object = v4() + ".txt";
await adapter.makeBucket(bucket);

// test
const result = await adapter.getObject({
bucket,
object,
useSignedUrl: true,
}).catch((err) => err);
assert(!result.ok);
assert(result.status === 501);
});

Deno.test("list files", async () => {
const bucket = v4();
const object = v4() + ".tmp";
Expand Down
2 changes: 1 addition & 1 deletion deps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * as R from "https://cdn.skypack.dev/[email protected]";
export { default as crocks } from "https://cdn.skypack.dev/[email protected]";

export * as path from "https://deno.land/std@0.135.0/path/mod.ts";
export * as path from "https://deno.land/std@0.153.0/path/mod.ts";

export {
HyperErr,
Expand Down
316 changes: 0 additions & 316 deletions deps_lock.json

This file was deleted.

6 changes: 3 additions & 3 deletions dev_deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export {
assert,
assertEquals,
assertObjectMatch,
} from "https://deno.land/std@0.127.0/testing/asserts.ts";
export { v4 } from "https://deno.land/std@0.127.0/uuid/mod.ts";
export { readAll } from "https://deno.land/std@0.127.0/io/util.ts";
} from "https://deno.land/std@0.153.0/testing/asserts.ts";
export { v4 } from "https://deno.land/std@0.153.0/uuid/mod.ts";
export { readAll } from "https://deno.land/std@0.153.0/io/util.ts";
19 changes: 0 additions & 19 deletions dev_deps_lock.json

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/lock.sh

This file was deleted.

4 changes: 2 additions & 2 deletions test/hyper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Harness deps
import { default as appOpine } from "https://x.nest.land/hyper-app-opine@2.0.0/mod.js";
import { default as core } from "https://x.nest.land/hyper@3.0.0/mod.js";
import { default as appOpine } from "https://x.nest.land/hyper-app-opine@2.2.0/mod.js";
import { default as core } from "https://x.nest.land/hyper@3.3.0/mod.js";

import fs from "../mod.js";

Expand Down