package recording
import "github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
Index ¶
- Constants
- func AddUriSanitizer(replacement, regex string, options *RecordingOptions) error
- func DefaultStringSanitizer(s *string)
- func GetEnvVariable(t *testing.T, varName string, recordedValue string) string
- func GetHTTPClient(t *testing.T) (*http.Client, error)
- func GetRecordMode() string
- func GetRecordingId(t *testing.T) string
- func IsLiveOnly(t *testing.T) bool
- func LiveOnly(t *testing.T)
- func Sleep(duration time.Duration)
- func StartRecording(t *testing.T, pathToRecordings string, options *RecordingOptions) error
- func StopRecording(t *testing.T, options *RecordingOptions) error
- type Failer
- type Logger
- type Name
- type RecordMode
- type Recording
- func NewRecording(c TestContext, mode RecordMode) (*Recording, error)
- func (r *Recording) Do(req *http.Request) (*http.Response, error)
- func (r *Recording) GenerateAlphaNumericID(prefix string, length int, lowercaseOnly bool) (string, error)
- func (r *Recording) GetEnvVar(name string, variableType VariableType) (string, error)
- func (r *Recording) GetOptionalEnvVar(name string, defaultValue string, variableType VariableType) string
- func (r *Recording) Now() time.Time
- func (r *Recording) Stop() error
- func (r *Recording) UUID() uuid.UUID
- type RecordingOptions
- type RequestMatcher
- func (m *RequestMatcher) SetBodyMatcher(matcher StringMatcher)
- func (m *RequestMatcher) SetMethodMatcher(matcher StringMatcher)
- func (m *RequestMatcher) SetURLMatcher(matcher StringMatcher)
- type Sanitizer
- func (s *Sanitizer) AddBodysanitizer(sanitizer StringSanitizer)
- func (s *Sanitizer) AddSanitizedHeaders(headers ...string)
- func (s *Sanitizer) AddUrlSanitizer(sanitizer StringSanitizer)
- type StringMatcher
- type StringSanitizer
- type TestContext
- type VariableType
Constants ¶
const ( RecordingMode = "record" PlaybackMode = "playback" LiveMode = "live" IdHeader = "x-recording-id" ModeHeader = "x-recording-mode" UpstreamUriHeader = "x-recording-upstream-base-uri" )
const (
ModeEnvironmentVariableName = "AZURE_TEST_MODE"
)
const SanitizedBase64Value string = "Kg=="
SanitizedBase64Value is the default placeholder value to be used for sanitized base-64 encoded strings.
const SanitizedValue string = "sanitized"
SanitizedValue is the default placeholder value to be used for sanitized strings.
Functions ¶
func AddUriSanitizer ¶
func AddUriSanitizer(replacement, regex string, options *RecordingOptions) error
func DefaultStringSanitizer ¶
func DefaultStringSanitizer(s *string)
func GetEnvVariable ¶
This looks up an environment variable and if it is not found, returns the recordedValue
func GetHTTPClient ¶
func GetRecordMode ¶
func GetRecordMode() string
func GetRecordingId ¶
func IsLiveOnly ¶
func LiveOnly ¶
func Sleep ¶
Function for sleeping during a test for `duration` seconds. This method will only execute when AZURE_RECORD_MODE = "record", if a test is running in playback this will be a noop.
func StartRecording ¶
func StartRecording(t *testing.T, pathToRecordings string, options *RecordingOptions) error
func StopRecording ¶
func StopRecording(t *testing.T, options *RecordingOptions) error
Types ¶
type Failer ¶
type Failer func(string)
type Logger ¶
type Logger func(string)
type Name ¶
type Name func() string
type RecordMode ¶
type RecordMode string
const ( Record RecordMode = "record" Playback RecordMode = "playback" Live RecordMode = "live" )
type Recording ¶
type Recording struct { SessionName string RecordingFile string VariablesFile string Mode RecordMode Sanitizer *Sanitizer Matcher *RequestMatcher // contains filtered or unexported fields }
func NewRecording ¶
func NewRecording(c TestContext, mode RecordMode) (*Recording, error)
NewRecording initializes a new Recording instance
func (*Recording) Do ¶
Do satisfies the azcore.Transport interface so that Recording can be used as the transport for recorded requests
func (*Recording) GenerateAlphaNumericID ¶
func (r *Recording) GenerateAlphaNumericID(prefix string, length int, lowercaseOnly bool) (string, error)
GenerateAlphaNumericID will generate a recorded random alpha numeric id if the recording has a randomSeed already set, the value will be generated from that seed, else a new random seed will be used
func (*Recording) GetEnvVar ¶
func (r *Recording) GetEnvVar(name string, variableType VariableType) (string, error)
GetEnvVar returns a recorded environment variable. If the variable is not found we return an error. variableType determines how the recorded variable will be saved.
func (*Recording) GetOptionalEnvVar ¶
func (r *Recording) GetOptionalEnvVar(name string, defaultValue string, variableType VariableType) string
GetOptionalEnvVar returns a recorded environment variable with a fallback default value. default Value configures the fallback value to be returned if the environment variable is not set. variableType determines how the recorded variable will be saved.
func (*Recording) Now ¶
func (*Recording) Stop ¶
Stop stops the recording and saves them, including any captured variables, to disk
func (*Recording) UUID ¶
type RecordingOptions ¶
func (RecordingOptions) HostScheme ¶
func (r RecordingOptions) HostScheme() string
func (*RecordingOptions) Init ¶
func (o *RecordingOptions) Init()
type RequestMatcher ¶
type RequestMatcher struct { // IgnoredHeaders is a map acting as a hash set of the header names that will be ignored for matching. // Modifying the keys in the map will affect how headers are matched for recordings. IgnoredHeaders map[string]struct{} // contains filtered or unexported fields }
func (*RequestMatcher) SetBodyMatcher ¶
func (m *RequestMatcher) SetBodyMatcher(matcher StringMatcher)
SetBodyMatcher replaces the default matching behavior with a custom StringMatcher that compares the string value of the request body payload with the string value of the recorded body payload.
func (*RequestMatcher) SetMethodMatcher ¶
func (m *RequestMatcher) SetMethodMatcher(matcher StringMatcher)
SetMethodMatcher replaces the default matching behavior with a custom StringMatcher that compares the string value of the request method with the string value of the recorded method
func (*RequestMatcher) SetURLMatcher ¶
func (m *RequestMatcher) SetURLMatcher(matcher StringMatcher)
SetURLMatcher replaces the default matching behavior with a custom StringMatcher that compares the string value of the request URL with the string value of the recorded URL
type Sanitizer ¶
type Sanitizer struct {
// contains filtered or unexported fields
}
func (*Sanitizer) AddBodysanitizer ¶
func (s *Sanitizer) AddBodysanitizer(sanitizer StringSanitizer)
AddBodysanitizer configures the supplied StringSanitizer to sanitize recording request and response bodies
func (*Sanitizer) AddSanitizedHeaders ¶
AddSanitizedHeaders adds the supplied header names to the list of headers to be sanitized on request and response recordings.
func (*Sanitizer) AddUrlSanitizer ¶
func (s *Sanitizer) AddUrlSanitizer(sanitizer StringSanitizer)
AddUriSanitizer configures the supplied StringSanitizer to sanitize recording request and response URLs
type StringMatcher ¶
type StringSanitizer ¶
type StringSanitizer func(*string)
StringSanitizer is a func that will modify the string pointed to by the parameter into a sanitized value.
type TestContext ¶
func NewTestContext ¶
func NewTestContext(failer Failer, logger Logger, name Name) TestContext
NewTestContext initializes a new TestContext
type VariableType ¶
type VariableType string
const ( // NoSanitization indicates that the recorded value should not be sanitized. NoSanitization VariableType = "default" // Secret_String indicates that the recorded value should be replaced with a sanitized value. Secret_String VariableType = "secret_string" // Secret_Base64String indicates that the recorded value should be replaced with a sanitized valid base-64 string value. Secret_Base64String VariableType = "secret_base64String" )
Source Files ¶
doc.go recording.go request_matcher.go sanitizer.go testcontext.go
- Version
- v0.8.0
- Published
- Oct 20, 2021
- Platform
- js/wasm
- Imports
- 21 packages
- Last checked
- 53 minutes ago –
Tools for package owners.