Documentation
¶
Index ¶
- Constants
- Variables
- func AgentkInfoObj() *server_api.AgentkInfo
- func AgentwInfoObj() *server_api.AgentwInfo
- func AssertCommonRequestParams(t *testing.T, r *http.Request, traceID trace.TraceID)
- func AssertGetJSONRequest(t *testing.T, r *http.Request)
- func AssertGetJSONRequestIsCorrect(t *testing.T, r *http.Request, traceID trace.TraceID)
- func AssertGetRequestIsCorrect(t *testing.T, r *http.Request, traceID trace.TraceID)
- func AssertInvalid(t *testing.T, tests []InvalidTestcase)
- func AssertJWTSignature(t *testing.T, r *http.Request)
- func AssertRequestAccept(t *testing.T, r *http.Request, accept string)
- func AssertRequestAcceptJSON(t *testing.T, r *http.Request)
- func AssertRequestContentTypeJSON(t *testing.T, r *http.Request) bool
- func AssertRequestMethod(t *testing.T, r *http.Request, method string)
- func AssertRequestUserAgent(t *testing.T, r *http.Request, userAgent string)
- func AssertValid(t *testing.T, tests []ValidTestcase)
- func CtxWithSpanContext(t *testing.T) (context.Context, trace.TraceID)
- func GenerateCACert(t *testing.T) (string, string, *x509.Certificate, crypto.PrivateKey)
- func GenerateCert(t *testing.T, name string, caCert *x509.Certificate, caKey crypto.PrivateKey) (string, string)
- func GenerateCertInMem(t *testing.T, name string, caCert *x509.Certificate, caKey crypto.PrivateKey) ([]byte, []byte)
- func IgnoreProxyEnv(t *testing.T)
- func InjectSpanContext(t *testing.T, ctx context.Context) (context.Context, trace.TraceID)
- func NewPollConfig(interval time.Duration) retry.PollConfig
- func ReadProtoJSONRequest(t *testing.T, r *http.Request, m proto.Message) bool
- func RecvMsg(value any) func(any) error
- func RespondWithJSON(t *testing.T, w http.ResponseWriter, response any)
- func RespondWithJSONAndStatus(t *testing.T, w http.ResponseWriter, statusCode int, response any)
- func RunnerControllerInfoObj() *server_api.RunnerControllerInfo
- func SetValue(target, value any)
- func SkipInCI(t testing.TB)
- func SkipNotIntegration(t testing.TB)
- type InvalidTestcase
- type ValidTestcase
Constants ¶
const ( KASUserAgent = "kas/v0.1-blabla/asdwd" AgentToken api.AgentToken = "123123" AuthSecretKey = "blablabla" ProjectID int64 = 321 UserID int64 = 456 ConfigProjectID int64 = 5 )
Variables ¶
var ( AgentkKey1 = api.AgentKey{ ID: 123, Type: api.AgentTypeKubernetes, } AgentkKey2 = api.AgentKey{ ID: 456, Type: api.AgentTypeKubernetes, } AgentwKey1 = api.AgentKey{ ID: 1123, Type: api.AgentTypeWorkspace, } RunnerControllerKey1 = api.AgentKey{ ID: 2102, Type: api.AgentTypeRunnerController, } RunnerKey1 = api.AgentKey{ ID: 3333, Type: api.AgentTypeRunner, } )
var Validator = protovalidate.GlobalValidator
Validator is the shared protovalidate validator for use in tests. Use this instead of protovalidate.GlobalValidator directly.
Functions ¶
func AgentkInfoObj ¶
func AgentkInfoObj() *server_api.AgentkInfo
func AgentwInfoObj ¶
func AgentwInfoObj() *server_api.AgentwInfo
func AssertInvalid ¶
func AssertInvalid(t *testing.T, tests []InvalidTestcase)
func AssertRequestUserAgent ¶
func AssertValid ¶
func AssertValid(t *testing.T, tests []ValidTestcase)
func GenerateCACert ¶
func GenerateCACert(t *testing.T) (string, string, *x509.Certificate, crypto.PrivateKey)
func GenerateCert ¶
func GenerateCert(t *testing.T, name string, caCert *x509.Certificate, caKey crypto.PrivateKey) (string, string)
func GenerateCertInMem ¶
func GenerateCertInMem(t *testing.T, name string, caCert *x509.Certificate, caKey crypto.PrivateKey) ([]byte, []byte)
func IgnoreProxyEnv ¶ added in v19.3.0
IgnoreProxyEnv empties the proxy environment variables for the duration of the test so that a proxy configured on the machine running the tests cannot intercept the requests the test makes. A test that expects a connection to fail needs this in particular: a proxy answers such a request instead of letting it fail.
This is for a test that exercises a client with its default transport. A client the test constructs itself is better told not to use a proxy at all, e.g. with gitlab.WithoutProxy(), which needs neither of the caveats below.
net/http resolves the proxy environment exactly once per process, on the first request made through http.ProxyFromEnvironment, and caches the result. Emptying the variables therefore only has an effect while no such request has been made yet, so every test in a package that makes them should call this: whichever runs first then populates the cache with an empty configuration for all the others.
Cannot be combined with t.Parallel(), because t.Setenv() forbids it.
func InjectSpanContext ¶
func NewPollConfig ¶
func NewPollConfig(interval time.Duration) retry.PollConfig
func ReadProtoJSONRequest ¶
func RespondWithJSON ¶
func RespondWithJSON(t *testing.T, w http.ResponseWriter, response any)
RespondWithJSON marshals response into JSON and writes it into w.
func RunnerControllerInfoObj ¶
func RunnerControllerInfoObj() *server_api.RunnerControllerInfo
func SetValue ¶
func SetValue(target, value any)
SetValue sets target to value with special handling for proto.Message. target must be a pointer. i.e. *blaProtoMsgType value must be of the same type as target.