Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jul 27, 2023
1 parent e8d43c0 commit 7ba6811
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func CreateFlags(defaultPath string) []cli.Flag {
},
&cli.StringFlag{
Name: "http.s3-bucket",
Usage: "Set the s3 bucket name to use for HTTP-01 based challenges. Challenges will be written to the s3 bucket.",
Usage: "Set the S3 bucket name to use for HTTP-01 based challenges. Challenges will be written to the S3 bucket.",
},
&cli.BoolFlag{
Name: "tls",
Expand Down
2 changes: 1 addition & 1 deletion docs/data/zz_cli_help.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ GLOBAL OPTIONS:
--http.proxy-header value Validate against this HTTP header when solving HTTP-01 based challenges behind a reverse proxy. (default: "Host")
--http.webroot value Set the webroot folder to use for HTTP-01 based challenges to write directly to the .well-known/acme-challenge file. This disables the built-in server and expects the given directory to be publicly served with access to .well-known/acme-challenge
--http.memcached-host value [ --http.memcached-host value ] Set the memcached host(s) to use for HTTP-01 based challenges. Challenges will be written to all specified hosts.
--http.s3-bucket value Set the s3 bucket name to use for HTTP-01 based challenges. Challenges will be written to the s3 bucket.
--http.s3-bucket value Set the S3 bucket name to use for HTTP-01 based challenges. Challenges will be written to the S3 bucket.
--tls Use the TLS-ALPN-01 challenge to solve challenges. Can be mixed with other types of challenges. (default: false)
--tls.port value Set the port and interface to use for TLS-ALPN-01 based challenges to listen on. Supported: interface:port or :port. (default: ":443")
--dns value Solve a DNS-01 challenge using the specified provider. Can be mixed with other types of challenges. Run 'lego dnshelp' for help on usage.
Expand Down
11 changes: 6 additions & 5 deletions providers/http/s3/s3.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name = "Amazon Route S3"
Name = "Amazon S3"
Description = ''''''
URL = "https://aws.amazon.com/s3/"
Code = "s3"
Expand Down Expand Up @@ -29,9 +29,10 @@ See also: https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/
### Broad privileges for testing purposes
Will need to create an s3 bucket which has read permissions set for Everyone(public access)
The s3 bucket doesn't require static website hosting to be enabled
AWS_REGION must match the region where the s3 bucket is hosted
Will need to create an S3 bucket which has read permissions set for Everyone (public access).
The S3 bucket doesn't require static website hosting to be enabled.
AWS_REGION must match the region where the s3 bucket is hosted.
'''

[Configuration]
[Configuration.Credentials]
Expand All @@ -50,4 +51,4 @@ AWS_REGION must match the region where the s3 bucket is hosted
[Links]
API = "https://docs.aws.amazon.com/AmazonS3/latest/userguide//Welcome.html"
GoClient = "https://docs.aws.amazon.com/sdk-for-go/"
'''

15 changes: 8 additions & 7 deletions providers/http/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"fmt"
"io"
"net/http"
"os"
"testing"


"github.com/go-acme/lego/v4/challenge/http01"
"github.com/go-acme/lego/v4/platform/tester"
"github.com/stretchr/testify/assert"
Expand All @@ -27,7 +27,7 @@ var envTest = tester.NewEnvTest(
"AWS_REGION",
"S3_BUCKET")

func TestNewS3ProviderValid(t *testing.T) {
func TestLiveNewHTTPProvider_Valid(t *testing.T) {
if !envTest.IsLiveTest() {
t.Skip("skipping live test")
}
Expand All @@ -38,22 +38,23 @@ func TestNewS3ProviderValid(t *testing.T) {
require.NoError(t, err)
}

func TestLiveS3ProviderPresent(t *testing.T) {
func TestLiveNewHTTPProvider(t *testing.T) {
if !envTest.IsLiveTest() {
t.Skip("skipping live test")
}

envTest.RestoreEnv()

s3Bucket := envTest.GetValue("S3_BUCKET")
s3Bucket := os.Getenv("S3_BUCKET")

provider, err := NewHTTPProvider(s3Bucket)
require.NoError(t, err)

// Present

err = provider.Present(domain, token, keyAuth)
require.NoError(t, err)


chlgPath := fmt.Sprintf("http://%s.s3.%s.amazonaws.com%s",
s3Bucket, envTest.GetValue("AWS_REGION"), http01.ChallengePath(token))

Expand All @@ -67,11 +68,11 @@ func TestLiveS3ProviderPresent(t *testing.T) {

assert.Equal(t, []byte(keyAuth), data)

// CleanUp

err = provider.CleanUp(domain, token, keyAuth)
require.NoError(t, err)



cleanupResp, err := http.Get(chlgPath)
require.NoError(t, err)

Expand Down

0 comments on commit 7ba6811

Please sign in to comment.