mirror of
https://github.com/ferdzo/fs.git
synced 2026-06-04 05:26:46 +00:00
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package auth
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestResolveTargetIncludesListBucketPrefix(t *testing.T) {
|
|
req := httptest.NewRequest(http.MethodGet, "http://example.com/test-bucket?list-type=2&prefix=allowed/", nil)
|
|
|
|
target := resolveTarget(req)
|
|
|
|
if target.Action != ActionListBucket {
|
|
t.Fatalf("action = %q, want %q", target.Action, ActionListBucket)
|
|
}
|
|
if target.Bucket != "test-bucket" {
|
|
t.Fatalf("bucket = %q, want test-bucket", target.Bucket)
|
|
}
|
|
if target.Prefix != "allowed/" {
|
|
t.Fatalf("prefix = %q, want allowed/", target.Prefix)
|
|
}
|
|
if target.Key != "" {
|
|
t.Fatalf("key = %q, want empty", target.Key)
|
|
}
|
|
}
|
|
|
|
func TestResolveTargetListBucketWithoutPrefix(t *testing.T) {
|
|
req := httptest.NewRequest(http.MethodGet, "http://example.com/test-bucket", nil)
|
|
|
|
target := resolveTarget(req)
|
|
|
|
if target.Action != ActionListBucket {
|
|
t.Fatalf("action = %q, want %q", target.Action, ActionListBucket)
|
|
}
|
|
if target.Prefix != "" {
|
|
t.Fatalf("prefix = %q, want empty", target.Prefix)
|
|
}
|
|
}
|