Documentation
¶
Overview ¶
Package s3stub is an S3 endpoint for tests (ADR-0203, ADR-0208): path-style object PUT, GET, HEAD, DELETE and CopyObject, ListObjectsV2 and ListObjectVersions over an in-memory bucket stamped by a manual clock, with the bucket's versioning and Object Lock answers set by the test.
Index ¶
- Constants
- func CredentialsFile(t testing.TB, keyID string) string
- func Main(m *testing.M)
- type Condition
- type Stub
- func (s *Stub) Endpoint() string
- func (s *Stub) ExpireNoncurrentLocked(key string)
- func (s *Stub) Keys(prefix string) []string
- func (s *Stub) Object(key string) (data []byte, contentType string, meta map[string]string, ok bool)
- func (s *Stub) PutKeys(prefix string) []string
- func (s *Stub) PutLocked(key string, data []byte)
- func (s *Stub) Seed(key string, data []byte)
- func (s *Stub) Seen() (requests, auth []string)
- func (s *Stub) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Stub) Set(f func(s *Stub))
- func (s *Stub) SetSize(key string, size int64)
- func (s *Stub) URL(params ...string) string
- func (s *Stub) VersionCount(key string) int
Constants ¶
const Bucket = "funcd-backup"
Bucket is the stub's bucket name.
const Drop = -1
Drop as a Status closes the connection without an answer.
Variables ¶
This section is empty.
Functions ¶
func CredentialsFile ¶
CredentialsFile writes an AWS shared credentials file whose [default] profile holds keyID.
Types ¶
type Stub ¶
type Stub struct {
Clock *clock.Manual
Cond Condition
Box bool
FailPut func(key string) bool
OnPut func(s *Stub, key string)
Versioning string
VersioningStatus int
ObjectLock bool
LockStatus int
// contains filtered or unexported fields
}
Stub is the endpoint. Set its fields through Set. Box refuses every object read and delete and every put under gen/verified/, as ADR-0203's box policy does; FailPut refuses chosen puts and copies; OnPut runs after each stored put, under the stub's lock (use PutLocked there). Versioning is the bucket's status ("", "Enabled", "Suspended"); VersioningStatus and LockStatus, when set, answer that read with the HTTP status (or Drop).
func (*Stub) ExpireNoncurrentLocked ¶
ExpireNoncurrentLocked drops every version of key but the current one, as a noncurrent-version expiry rule does; call it under the stub's lock.
func (*Stub) Object ¶
func (s *Stub) Object(key string) (data []byte, contentType string, meta map[string]string, ok bool)
Object returns key's current bytes, content type and metadata.
func (*Stub) PutLocked ¶
PutLocked stores an object; call it under the stub's lock (from OnPut or Set).
func (*Stub) Seen ¶
Seen returns every request ("<method> <key>", a sub-resource as "?<name>") and its Authorization header.
func (*Stub) SetSize ¶
SetSize makes key's current version list with size bytes, for a test of a size limit.
func (*Stub) VersionCount ¶
VersionCount returns how many versions and delete markers key has.