MCPcopy Create free account
hub / github.com/elimity-com/scim / TestOperationValidator_getRefAttribute

Function TestOperationValidator_getRefAttribute

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

Source from the content-addressed store, hash-verified

34}
35
36func TestOperationValidator_getRefAttribute(t *testing.T) {
37 for _, test := range []struct {
38 pathFilter string
39 expectedAttrName string
40 }{
41 {`userName`, `userName`},
42 {`name.givenName`, `givenName`},
43 {`urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:employeeNumber`, `employeeNumber`},
44 } {
45 validator, err := NewValidator(
46 fmt.Sprintf(`{"op":"invalid","path":%q,"value":"value"}`, test.pathFilter),
47 schema.CoreUserSchema(), schema.ExtensionEnterpriseUser(),
48 )
49 if err != nil {
50 t.Fatal(err)
51 }
52 attr, err := validator.getRefAttribute(validator.Path.AttributePath)
53 if err != nil {
54 t.Fatal(err)
55 }
56 if name := attr.Name(); name != test.expectedAttrName {
57 t.Errorf("expected %s, got %s", test.expectedAttrName, name)
58 }
59 }
60
61 validator, _ := NewValidator(
62 `{"op":"invalid","path":"complex","value":"value"}`,
63 schema.CoreUserSchema(), schema.ExtensionEnterpriseUser(),
64 )
65 if _, err := validator.getRefAttribute(filter.AttributePath{
66 AttributeName: "invalid",
67 }); err == nil {
68 t.Error("expected an error, got nil")
69 }
70}
71
72func TestOperationValidator_getRefSubAttribute(t *testing.T) {
73 for _, test := range []struct {

Callers

nothing calls this directly

Calls 6

CoreUserSchemaFunction · 0.92
ExtensionEnterpriseUserFunction · 0.92
getRefAttributeMethod · 0.80
NameMethod · 0.80
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…