mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
* admin: show the configured S3 endpoint in the service account CLI example The credentials modal always printed AWS_ENDPOINT_URL=http://localhost:8333. Use s3.public_endpoint from admin.toml (or weed mini's own S3 address) when it is set, and keep localhost:8333 only as the fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: test the service account CLI example endpoint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: shell-quote the S3 endpoint in the service account CLI example A configured endpoint may contain characters such as ';' in its path, which would split the copied export command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package app
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/admin/dash"
|
|
)
|
|
|
|
func TestServiceAccountsCLIExampleUsesS3Endpoint(t *testing.T) {
|
|
tests := []struct {
|
|
endpoint string
|
|
want string
|
|
}{
|
|
{endpoint: "https://s3.example.com", want: "export AWS_ENDPOINT_URL=https://s3.example.com<"},
|
|
{endpoint: "https://proxy.example.com/s3;v1", want: "export AWS_ENDPOINT_URL='https://proxy.example.com/s3;v1'<"},
|
|
{endpoint: "", want: "export AWS_ENDPOINT_URL=http://localhost:8333<"},
|
|
}
|
|
for _, tt := range tests {
|
|
var buf bytes.Buffer
|
|
if err := ServiceAccounts(dash.ServiceAccountsData{S3Endpoint: tt.endpoint}).Render(context.Background(), &buf); err != nil {
|
|
t.Fatalf("render with endpoint %q: %v", tt.endpoint, err)
|
|
}
|
|
got := buf.String()
|
|
if !strings.Contains(got, tt.want) {
|
|
t.Errorf("endpoint %q: page is missing %q", tt.endpoint, tt.want)
|
|
}
|
|
if tt.endpoint != "" && strings.Contains(got, "localhost:8333") {
|
|
t.Errorf("endpoint %q: page still shows localhost:8333", tt.endpoint)
|
|
}
|
|
}
|
|
}
|