MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / TestNewAccessValidatorOk

Function TestNewAccessValidatorOk

validation/validation_test.go:116–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestNewAccessValidatorOk(t *testing.T) {
117 ctx := context.Background()
118 url := "test.cloudflareaccess.com"
119 access, err := NewAccessValidator(ctx, url, url, "")
120
121 assert.NoError(t, err)
122 assert.NotNil(t, access)
123
124 assert.Error(t, access.Validate(ctx, ""))
125 assert.Error(t, access.Validate(ctx, "invalid"))
126
127 req := httptest.NewRequest("GET", "https://test.cloudflareaccess.com", nil)
128 req.Header.Set(accessJwtHeader, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
129 assert.Error(t, access.ValidateRequest(ctx, req))
130}
131
132func TestNewAccessValidatorErr(t *testing.T) {
133 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

NewAccessValidatorFunction · 0.85
ValidateRequestMethod · 0.80
ErrorMethod · 0.45
ValidateMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected