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

updated dependencies, had to fix a few tests #67

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
go-version: [1.20.x, 1.21.x]
runs-on: ubuntu-latest
services:
localstack:
Expand All @@ -17,7 +17,7 @@ jobs:
env:
AWS_SECRET_ACCESS_KEY: dummy
AWS_ACCESS_KEY_ID: dummy
AWS_REGION: dummy
AWS_REGION: us-west-2
AWS_ENDPOINT: http://localhost:4566
steps:
- name: Install Go
Expand Down
31 changes: 31 additions & 0 deletions .standard-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# DO NOT EDIT
#
# This wil will be auto-updated by checkdeps to match the version in
# extraction-makeworld/configs/checkdeps/standard-lint.yml
#
# If you NEED to have custom lint rules for a paticular repository you can change the name
# of this file make your updates. Then change the lint target in the Makefile to reference your
# custom file.
#
# If we need to update this config to add new linters, get rid of deprecated linters, etc. You can just make
# the change in makeworld and then it will propogate to all repos using this file as developers run
# checkdeps --fix in those repos.

run:
timeout: 5m
linters:
disable-all: true
enable:
- staticcheck
- unused
- gofmt
- goimports
- govet
- errcheck
- gosimple
- ineffassign
- typecheck
- gosec
linters-settings:
goimports:
local-prefixes: github.com/lindenlab
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export GO111MODULE=on
VERSION := $(shell cat Version)
COVER_TARGET ?= 30

export GO111MODULE=on

# Set for running tests against localstack
export AWS_SECRET_ACCESS_KEY=dummy
export AWS_ACCESS_KEY_ID=dummy
Expand Down Expand Up @@ -32,7 +33,7 @@ cover: ## Generate test coverage results

.PHONY: lint
lint: ## Run golint on source base
@golangci-lint run ./...
@golangci-lint run --config .standard-lint.yml ./...

.PHONY: localstack
localstack: ## Launch localstack to run tests against
Expand All @@ -51,6 +52,7 @@ awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
.PHONY: clean
clean: ## Delete any generated files
@rm -f caddy
@rm -f cover.profile cover.html cover.func

.PHONY: version
version: ## Show the version the Makefile will build
Expand Down
2 changes: 1 addition & 1 deletion Version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.8
0.5.9
18 changes: 9 additions & 9 deletions browse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestConstructListObjInput(t *testing.T) {
}

testCases := []testCase{
testCase{
{
name: "no query options",
bucket: "myBucket",
key: "/mypath/",
Expand All @@ -31,7 +31,7 @@ func TestConstructListObjInput(t *testing.T) {
Prefix: aws.String("mypath/"),
},
},
testCase{
{
name: "max option",
bucket: "myBucket",
key: "/mypath/",
Expand All @@ -43,7 +43,7 @@ func TestConstructListObjInput(t *testing.T) {
MaxKeys: aws.Int64(20),
},
},
testCase{
{
name: "max with next",
bucket: "myBucket",
key: "/mypath/",
Expand Down Expand Up @@ -78,15 +78,15 @@ func TestMakePageObj(t *testing.T) {
NextContinuationToken: aws.String("next_token"),
MaxKeys: aws.Int64(20),
CommonPrefixes: []*s3.CommonPrefix{
&s3.CommonPrefix{
{
Prefix: aws.String("/mydir"),
},
&s3.CommonPrefix{
{
Prefix: aws.String("/otherdir"),
},
},
Contents: []*s3.Object{
&s3.Object{
{
Key: aws.String("/path/to/myobj"),
Size: aws.Int64(1024),
LastModified: aws.Time(time.Date(1845, time.November, 10, 23, 0, 0, 0, time.UTC)),
Expand All @@ -99,17 +99,17 @@ func TestMakePageObj(t *testing.T) {
Count: 20,
MoreLink: "?max=20&next=next_token",
Items: []Item{
Item{
{
Url: "./mydir/",
IsDir: true,
Name: "mydir",
},
Item{
{
Url: "./otherdir/",
IsDir: true,
Name: "otherdir",
},
Item{
{
Url: "./myobj",
Key: "/path/to/myobj",
IsDir: false,
Expand Down
31 changes: 15 additions & 16 deletions caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ func init() {
// parseCaddyfile parses the s3proxy directive. It enables the proxying
// requests to S3 and configures it with this syntax:
//
// s3proxy [<matcher>] {
// root <path to prefix S3 key with>
// region <aws region>
// profile <aws profile>
// bucket <s3 bucket name>
// index <files...>
// hide <file patterns...>
// endpoint <alternative endpoint>
// enable_put
// enable_delete
// force_path_style
// use_accelerate
// errors [<http code>] [<s3 key to error page>|pass_through]
// browse [<template file>]
// }
//
// s3proxy [<matcher>] {
// root <path to prefix S3 key with>
// region <aws region>
// profile <aws profile>
// bucket <s3 bucket name>
// index <files...>
// hide <file patterns...>
// endpoint <alternative endpoint>
// enable_put
// enable_delete
// force_path_style
// use_accelerate
// errors [<http code>] [<s3 key to error page>|pass_through]
// browse [<template file>]
// }
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
return parseCaddyfileWithDispenser(h.Dispenser)
}
Expand Down
56 changes: 28 additions & 28 deletions caddyfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,81 +17,81 @@ type testCase struct {

func TestParseCaddyfile(t *testing.T) {
testCases := []testCase{
testCase{
{
desc: "bad sub directive",
input: `s3proxy {
foo
}`,
shouldErr: true,
errString: "Testfile:2 - Error during parsing: foo not a valid s3proxy option",
errString: "foo not a valid s3proxy option, at Testfile:2",
},
testCase{
{
desc: "bucket bad # args",
input: `s3proxy {
bucket
}`,
shouldErr: true,
errString: "Testfile:2 - Error during parsing: Wrong argument count or unexpected line ending after 'bucket'",
errString: "wrong argument count or unexpected line ending after 'bucket', at Testfile:2",
},
testCase{
{
desc: "bucket empty string",
input: `s3proxy {
bucket ""
}`,
shouldErr: true,
errString: "Testfile:2 - Error during parsing: bucket must be set and not empty",
errString: "bucket must be set and not empty, at Testfile:2",
},
testCase{
{
desc: "bucket missing",
input: `s3proxy {
region foo
}`,
shouldErr: true,
errString: "Testfile:3 - Error during parsing: bucket must be set and not empty",
errString: "bucket must be set and not empty, at Testfile:3",
},
testCase{
{
desc: "endpoint bad # args",
input: `s3proxy {
endpoint
}`,
shouldErr: true,
errString: "Testfile:2 - Error during parsing: Wrong argument count or unexpected line ending after 'endpoint'",
errString: "wrong argument count or unexpected line ending after 'endpoint', at Testfile:2",
},
testCase{
{
desc: "region bad # args",
input: `s3proxy {
region one two
}`,
shouldErr: true,
errString: "Testfile:2 - Error during parsing: Wrong argument count or unexpected line ending after 'one'",
errString: "wrong argument count or unexpected line ending after 'one', at Testfile:2",
},
testCase{
{
desc: "root bad # args",
input: `s3proxy {
root one two
}`,
shouldErr: true,
errString: "Testfile:2 - Error during parsing: Wrong argument count or unexpected line ending after 'one'",
errString: "wrong argument count or unexpected line ending after 'one', at Testfile:2",
},
testCase{
{
desc: "errors on invalid HTTP status for errors",
input: `s3proxy {
bucket mybucket
errors invalid "path/to/404.html"
}`,
shouldErr: true,
errString: "Testfile:3 - Error during parsing: 'invalid' is not a valid HTTP status code",
errString: "'invalid' is not a valid HTTP status code, at Testfile:3",
},
testCase{
{
desc: "errors on too many arguments for errors",
input: `s3proxy {
bucket mybucket
errors 403 "path/to/404.html" "what's this?"
}`,
shouldErr: true,
errString: "Testfile:3 - Error during parsing: Wrong argument count or unexpected line ending after 'what's this?'",
errString: "wrong argument count or unexpected line ending after 'what's this?', at Testfile:3",
},
testCase{
{
desc: "endpoint gets set",
input: `s3proxy {
bucket mybucket
Expand All @@ -105,7 +105,7 @@ func TestParseCaddyfile(t *testing.T) {
Region: "myregion",
},
},
testCase{
{
desc: "enable pu",
input: `s3proxy {
bucket mybucket
Expand All @@ -117,7 +117,7 @@ func TestParseCaddyfile(t *testing.T) {
EnablePut: true,
},
},
testCase{
{
desc: "enable delete",
input: `s3proxy {
bucket mybucket
Expand All @@ -129,7 +129,7 @@ func TestParseCaddyfile(t *testing.T) {
EnableDelete: true,
},
},
testCase{
{
desc: "enable error pages",
input: `s3proxy {
bucket mybucket
Expand All @@ -147,7 +147,7 @@ func TestParseCaddyfile(t *testing.T) {
DefaultErrorPage: "path/to/default_error.html",
},
},
testCase{
{
desc: "hide files",
input: `s3proxy {
bucket mybucket
Expand All @@ -159,16 +159,16 @@ func TestParseCaddyfile(t *testing.T) {
Hide: []string{"foo.txt", "_*"},
},
},
testCase{
{
desc: "hide files - missing arg",
input: `s3proxy {
bucket mybucket
hide
}`,
shouldErr: true,
errString: "Testfile:3 - Error during parsing: Wrong argument count or unexpected line ending after 'hide'",
errString: "wrong argument count or unexpected line ending after 'hide', at Testfile:3",
},
testCase{
{
desc: "index test",
input: `s3proxy {
bucket mybucket
Expand All @@ -180,14 +180,14 @@ func TestParseCaddyfile(t *testing.T) {
IndexNames: []string{"i.htm", "i.html"},
},
},
testCase{
{
desc: "index - missing arg",
input: `s3proxy {
bucket mybucket
index
}`,
shouldErr: true,
errString: "Testfile:3 - Error during parsing: Wrong argument count or unexpected line ending after 'index'",
errString: "wrong argument count or unexpected line ending after 'index', at Testfile:3",
},
}

Expand Down
25 changes: 3 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,8 @@ module github.com/lindenlab/caddy-s3-proxy
go 1.13

require (
github.com/alecthomas/chroma v0.8.2 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b // indirect
github.com/aws/aws-sdk-go v1.44.272
github.com/caddyserver/caddy/v2 v2.6.4
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/aws/aws-sdk-go v1.48.16
github.com/caddyserver/caddy/v2 v2.7.6
github.com/dustin/go-humanize v1.0.1
github.com/google/cel-go v0.13.0 // indirect
github.com/google/cel-spec v0.4.0 // indirect
github.com/jsternberg/zap-logfmt v1.2.0 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/lucas-clemente/quic-go v0.19.3 // indirect
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/naoina/toml v0.1.1 // indirect
github.com/smallstep/certificates v0.23.2 // indirect
github.com/smallstep/cli v0.15.2 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 // indirect
go.step.sm/crypto v0.23.2 // indirect
go.step.sm/linkedca v0.19.1 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0
gopkg.in/yaml.v3 v3.0.1 // indirect
go.uber.org/zap v1.25.0
)
Loading
Loading