MCPcopy Index your code
hub / github.com/elimity-com/scim / TestNewPathValidator

Function TestNewPathValidator

internal/patch/patch_test.go:10–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestNewPathValidator(t *testing.T) {
11 t.Run("Invalid JSON", func(t *testing.T) {
12 // The quotes in the value filter are not escaped.
13 op := `{"op":"add","path":"complexMultiValued[attr1 eq "value"].attr1","value":"value"}`
14 if _, err := NewValidator(op, patchSchema); err == nil {
15 t.Error("expected JSON error, got none")
16 }
17 })
18 t.Run("Invalid Op", func(t *testing.T) {
19 // "op" must be one of "add", "remove", or "replace".
20 op := `{"op":"invalid","path":"attr1","value":"value"}`
21 validator, _ := NewValidator(op, patchSchema)
22 if _, err := validator.Validate(); err == nil {
23 t.Errorf("expected error, got none")
24 }
25 })
26 t.Run("Invalid Attribute", func(t *testing.T) {
27 // "invalid pr" is not a valid path filter.
28 // This error will be caught by the path filter validator.
29 op := `{"op":"add","path":"invalid pr","value":"value"}`
30 if _, err := NewValidator(op, patchSchema); err == nil {
31 t.Error("expected JSON error, got none")
32 }
33 })
34}
35
36func TestOperationValidator_getRefAttribute(t *testing.T) {
37 for _, test := range []struct {

Callers

nothing calls this directly

Calls 3

ValidateMethod · 0.95
ErrorMethod · 0.80
NewValidatorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…