Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for JSON resource marshaling #2527

Merged
merged 1 commit into from Oct 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 76 additions & 0 deletions github/scim_test.go
Expand Up @@ -464,3 +464,79 @@ func TestSCIMUserName_Marshal(t *testing.T) {
}`
testJSONMarshal(t, u, want)
}

func TestSCIMMeta_Marshal(t *testing.T) {
testJSONMarshal(t, &SCIMMeta{}, `{}`)

u := &SCIMMeta{
ResourceType: String("test"),
Location: String("test"),
}

want := `{
"resourceType": "test",
"location": "test"
}`

testJSONMarshal(t, u, want)
}

func TestSCIMProvisionedIdentities_Marshal(t *testing.T) {
testJSONMarshal(t, &SCIMProvisionedIdentities{}, `{}`)

u := &SCIMProvisionedIdentities{
Schemas: []string{"test", "schema"},
TotalResults: Int(1),
ItemsPerPage: Int(2),
StartIndex: Int(1),
Resources: []*SCIMUserAttributes{
{
UserName: "SCIM",
Name: SCIMUserName{
GivenName: "scim",
FamilyName: "test",
Formatted: String("SCIM"),
},
DisplayName: String("Test SCIM"),
Emails: []*SCIMUserEmail{
{
Value: "test",
Primary: Bool(true),
Type: String("test"),
},
},
Schemas: []string{"schema1"},
ExternalID: String("id"),
Groups: []string{"group1"},
Active: Bool(true),
},
},
}

want := `{
"schemas": ["test", "schema"],
"totalResults": 1,
"itemsPerPage": 2,
"startIndex": 1,
"Resources": [{
"userName": "SCIM",
"name": {
"givenName": "scim",
"familyName": "test",
"formatted": "SCIM"
},
"displayName": "Test SCIM",
"emails": [{
"value": "test",
"primary": true,
"type": "test"
}],
"schemas": ["schema1"],
"externalId": "id",
"groups": ["group1"],
"active": true
}]
}`

testJSONMarshal(t, u, want)
}