From 35b4faa0c1cab581624187d78c450ec632f291ed Mon Sep 17 00:00:00 2001 From: Harikesh Prajapati Date: Tue, 25 Oct 2022 15:13:49 +0530 Subject: [PATCH 1/7] Added test cases for JSON resource marshaling --- github/users_test.go | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/github/users_test.go b/github/users_test.go index 8acd529caa..66cf3d98e8 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -59,6 +59,89 @@ func TestUser_Marshal(t *testing.T) { "url": "u" }` testJSONMarshal(t, u, want) + + u2 := &User{ + Login: String("testLogin"), + ID: Int64(1), + NodeID: String("testNode123"), + AvatarURL: String("https://www.my-avatar.com"), + HTMLURL: String("https://www.test-url.com"), + GravatarID: String("testGravatar123"), + Name: String("myName"), + Company: String("testCompany"), + Blog: String("test Blog"), + Location: String("test location"), + Email: String("test@test.com"), + Hireable: Bool(true), + Bio: String("my good bio"), + TwitterUsername: String("https:www.twitter.com/test"), + PublicRepos: Int(1), + PublicGists: Int(2), + Followers: Int(100), + Following: Int(29), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + SuspendedAt: &Timestamp{referenceTime}, + Type: String("test type"), + SiteAdmin: Bool(false), + TotalPrivateRepos: Int(2), + OwnedPrivateRepos: Int(1), + PrivateGists: Int(1), + DiskUsage: Int(1), + Collaborators: Int(1), + TwoFactorAuthentication: Bool(false), + Plan: &Plan{ + Name: String("silver"), + Space: Int(1024), + Collaborators: Int(10), + PrivateRepos: Int(4), + FilledSeats: Int(24), + Seats: Int(1), + }, + LdapDn: String("test ldap"), + } + + want2 := `{ + "login": "testLogin", + "id": 1, + "node_id":"testNode123", + "avatar_url": "https://www.my-avatar.com", + "html_url":"https://www.test-url.com", + "gravatar_id": "testGravatar123", + "name": "myName", + "company": "testCompany", + "blog": "test Blog", + "location": "test location", + "email": "test@test.com", + "hireable": true, + "bio": "my good bio", + "twitter_username": "https:www.twitter.com/test", + "public_repos": 1, + "public_gists":2, + "followers": 100, + "following": 29, + "created_at": ` + referenceTimeStr + `, + "suspended_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "type": "test type", + "site_admin": false, + "total_private_repos": 2, + "owned_private_repos": 1, + "private_gists": 1, + "disk_usage": 1, + "collaborators": 1, + "two_factor_authentication": false, + "plan": { + "name": "silver", + "space": 1024, + "collaborators": 10, + "private_repos": 4, + "filled_seats": 24, + "seats": 1 + }, + "ldap_dn": "test ldap" + }` + testJSONMarshal(t, u2, want2) } func TestUsersService_Get_authenticatedUser(t *testing.T) { From 3c66d7d180c62509f283fc7ac9388eda2b8f66ce Mon Sep 17 00:00:00 2001 From: Akshay <48827972+akshaypatil3096@users.noreply.github.com> Date: Tue, 25 Oct 2022 18:43:00 +0530 Subject: [PATCH 2/7] Add test case for JSON resource marshaling (#2517) --- github/teams_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/github/teams_test.go b/github/teams_test.go index 83f559beff..cee6ff433e 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -2098,3 +2098,39 @@ func TestTeamsService_RemoveConnectedExternalGroup_notFound(t *testing.T) { t.Errorf("Teams.GetExternalGroup returned status %d, want %d", got, want) } } + +func TestIDPGroupList_Marshal(t *testing.T) { + testJSONMarshal(t, &IDPGroupList{}, "{}") + + u := &IDPGroupList{ + Groups: []*IDPGroup{ + { + GroupID: String("abc1"), + GroupName: String("test group"), + GroupDescription: String("test group descripation"), + }, + { + GroupID: String("abc2"), + GroupName: String("test group2"), + GroupDescription: String("test group descripation2"), + }, + }, + } + + want := `{ + "groups": [ + { + "group_id": "abc1", + "group_name": "test group", + "group_description": "test group descripation" + }, + { + "group_id": "abc2", + "group_name": "test group2", + "group_description": "test group descripation2" + } + ] + }` + + testJSONMarshal(t, u, want) +} From 922385f962be302088af28b7d63b5e559348b937 Mon Sep 17 00:00:00 2001 From: vaibhavgholap23 <91172267+vaibhavgholap23@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:18:47 +0530 Subject: [PATCH 3/7] Add test case for JSON resource marshaling (#2526) --- github/scim_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/github/scim_test.go b/github/scim_test.go index 7c6e14078b..d00377a972 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -389,3 +389,23 @@ func TestSCIMUserAttributes_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestSCIMUserName_Marshal(t *testing.T) { + testJSONMarshal(t, &SCIMUserName{}, `{ + "givenName":"","familyName":"" + }`) + + u := &SCIMUserName{ + GivenName: "Name1", + FamilyName: "Fname", + Formatted: String("formatted name"), + } + + want := `{ + "givenName": "Name1", + "familyName": "Fname", + "formatted": "formatted name" + }` + + testJSONMarshal(t, u, want) +} From 2a3d83e682dbbbef9aad8bc7bd4898c60ea49973 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:15:28 -0400 Subject: [PATCH 4/7] Fix typo in README URL (#2514) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 376d068662..0f99698d17 100644 --- a/README.md +++ b/README.md @@ -123,10 +123,10 @@ GitHub Apps authentication can be provided by the [ghinstallation](https://githu package. > **Note**: Most endpoints (ex. [`GET /rate_limit`]) require access token authentication -> while a few others (ex. [`GET /app/hook/deliverires`]) require [JWT] authentication. +> while a few others (ex. [`GET /app/hook/deliveries`]) require [JWT] authentication. [`GET /rate_limit`]: https://docs.github.com/en/rest/rate-limit#get-rate-limit-status-for-the-authenticated-user -[`GET /app/hook/deliverires`]: https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook +[`GET /app/hook/deliveries`]: https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook [JWT]: https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app From 8b03a1a7a80b75832947bb35160e57635581b62f Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:16:10 -0400 Subject: [PATCH 5/7] Update workflow to use Go 1.19 and Go 1.18 (#2525) --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0b2038712f..3a0366d42e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: contents: read # for actions/checkout to fetch code strategy: matrix: - go-version: [1.x, 1.17.x] + go-version: [1.x, 1.18.x] platform: [ubuntu-latest] include: # include windows, but only with the latest Go version, since there From 863155e24de5c299365a871b63c893e20bc4e519 Mon Sep 17 00:00:00 2001 From: Sayali Deshmukh <85864673+sayalideshmukh10@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:54:51 -0400 Subject: [PATCH 6/7] Add test cases for JSON resource marshaling (#2524) --- github/scim_test.go | 57 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/github/scim_test.go b/github/scim_test.go index d00377a972..7665bb2b12 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -390,6 +390,62 @@ func TestSCIMUserAttributes_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } +func TestUpdateAttributeForSCIMUserOperations_Marshal(t *testing.T) { + testJSONMarshal(t, &UpdateAttributeForSCIMUserOperations{}, `{}`) + + u := &UpdateAttributeForSCIMUserOperations{ + Op: "TestOp", + Path: String("path"), + } + + want := `{ + "op": "TestOp", + "path": "path" + }` + + testJSONMarshal(t, u, want) +} + +func TestUpdateAttributeForSCIMUserOptions_Marshal(t *testing.T) { + testJSONMarshal(t, &UpdateAttributeForSCIMUserOptions{}, `{}`) + + u := &UpdateAttributeForSCIMUserOptions{ + Schemas: []string{"test", "schema"}, + Operations: UpdateAttributeForSCIMUserOperations{ + Op: "TestOp", + Path: String("path"), + }, + } + + want := `{ + "schemas": ["test", "schema"], + "operations": { + "op": "TestOp", + "path": "path" + } + }` + + testJSONMarshal(t, u, want) +} + +func TestListSCIMProvisionedIdentitiesOptions_Marshal(t *testing.T) { + testJSONMarshal(t, &ListSCIMProvisionedIdentitiesOptions{}, `{}`) + + u := &ListSCIMProvisionedIdentitiesOptions{ + StartIndex: Int(1), + Count: Int(10), + Filter: String("test"), + } + + want := `{ + "startIndex": 1, + "count": 10, + "filter": "test" + }` + + testJSONMarshal(t, u, want) +} + func TestSCIMUserName_Marshal(t *testing.T) { testJSONMarshal(t, &SCIMUserName{}, `{ "givenName":"","familyName":"" @@ -406,6 +462,5 @@ func TestSCIMUserName_Marshal(t *testing.T) { "familyName": "Fname", "formatted": "formatted name" }` - testJSONMarshal(t, u, want) } From a83cd5d6a4342765fc6e3ba158d84d341fd4b7bb Mon Sep 17 00:00:00 2001 From: Harikesh Prajapati Date: Tue, 25 Oct 2022 15:13:49 +0530 Subject: [PATCH 7/7] Added test cases for JSON resource marshaling --- github/users_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/users_test.go b/github/users_test.go index 66cf3d98e8..204b31e171 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -74,7 +74,7 @@ func TestUser_Marshal(t *testing.T) { Email: String("test@test.com"), Hireable: Bool(true), Bio: String("my good bio"), - TwitterUsername: String("https:www.twitter.com/test"), + TwitterUsername: String("https://www.twitter.com/test"), PublicRepos: Int(1), PublicGists: Int(2), Followers: Int(100), @@ -115,7 +115,7 @@ func TestUser_Marshal(t *testing.T) { "email": "test@test.com", "hireable": true, "bio": "my good bio", - "twitter_username": "https:www.twitter.com/test", + "twitter_username": "https://www.twitter.com/test", "public_repos": 1, "public_gists":2, "followers": 100,