@@ -1763,10 +1763,12 @@ func Test_GetIssueComments(t *testing.T) {
17631763 tests := []struct {
17641764 name string
17651765 mockedClient * http.Client
1766+ gqlHTTPClient * http.Client
17661767 requestArgs map [string ]interface {}
17671768 expectError bool
17681769 expectedComments []* github.IssueComment
17691770 expectedErrMsg string
1771+ lockdownEnabled bool
17701772 }{
17711773 {
17721774 name : "successful comments retrieval" ,
@@ -1782,7 +1784,6 @@ func Test_GetIssueComments(t *testing.T) {
17821784 "repo" : "repo" ,
17831785 "issue_number" : float64 (42 ),
17841786 },
1785- expectError : false ,
17861787 expectedComments : mockComments ,
17871788 },
17881789 {
@@ -1809,6 +1810,27 @@ func Test_GetIssueComments(t *testing.T) {
18091810 expectError : false ,
18101811 expectedComments : mockComments ,
18111812 },
1813+ {
1814+ name : "lockdown enabled removes comments without push access" ,
1815+ mockedClient : mock .NewMockedHTTPClient (
1816+ mock .WithRequestMatch (
1817+ mock .GetReposIssuesCommentsByOwnerByRepoByIssueNumber ,
1818+ mockComments ,
1819+ ),
1820+ ),
1821+ gqlHTTPClient : newLockdownMockGQLHTTPClient (t , false , map [string ]string {
1822+ "user1" : "WRITE" ,
1823+ "user2" : "READ" ,
1824+ }),
1825+ requestArgs : map [string ]interface {}{
1826+ "method" : "get_comments" ,
1827+ "owner" : "owner" ,
1828+ "repo" : "repo" ,
1829+ "issue_number" : float64 (42 ),
1830+ },
1831+ expectedComments : []* github.IssueComment {mockComments [0 ]},
1832+ lockdownEnabled : true ,
1833+ },
18121834 {
18131835 name : "issue not found" ,
18141836 mockedClient : mock .NewMockedHTTPClient (
@@ -1832,8 +1854,14 @@ func Test_GetIssueComments(t *testing.T) {
18321854 t .Run (tc .name , func (t * testing.T ) {
18331855 // Setup client with mock
18341856 client := github .NewClient (tc .mockedClient )
1835- gqlClient := githubv4 .NewClient (nil )
1836- _ , handler := IssueRead (stubGetClientFn (client ), stubGetGQLClientFn (gqlClient ), translations .NullTranslationHelper , stubFeatureFlags (map [string ]bool {"lockdown-mode" : false }))
1857+ var gqlClient * githubv4.Client
1858+ if tc .gqlHTTPClient != nil {
1859+ gqlClient = githubv4 .NewClient (tc .gqlHTTPClient )
1860+ } else {
1861+ gqlClient = githubv4 .NewClient (nil )
1862+ }
1863+ flags := stubFeatureFlags (map [string ]bool {"lockdown-mode" : tc .lockdownEnabled })
1864+ _ , handler := IssueRead (stubGetClientFn (client ), stubGetGQLClientFn (gqlClient ), translations .NullTranslationHelper , flags )
18371865
18381866 // Create call request
18391867 request := createMCPRequest (tc .requestArgs )
@@ -1856,9 +1884,9 @@ func Test_GetIssueComments(t *testing.T) {
18561884 err = json .Unmarshal ([]byte (textContent .Text ), & returnedComments )
18571885 require .NoError (t , err )
18581886 assert .Equal (t , len (tc .expectedComments ), len (returnedComments ))
1859- if len ( returnedComments ) > 0 {
1860- assert .Equal (t , * tc .expectedComments [0 ].Body , * returnedComments [0 ].Body )
1861- assert .Equal (t , * tc .expectedComments [0 ].User .Login , * returnedComments [0 ].User .Login )
1887+ for i := range returnedComments {
1888+ assert .Equal (t , * tc .expectedComments [i ].Body , * returnedComments [i ].Body )
1889+ assert .Equal (t , * tc .expectedComments [i ].User .Login , * returnedComments [i ].User .Login )
18621890 }
18631891 })
18641892 }
@@ -2686,10 +2714,12 @@ func Test_GetSubIssues(t *testing.T) {
26862714 tests := []struct {
26872715 name string
26882716 mockedClient * http.Client
2717+ gqlHTTPClient * http.Client
26892718 requestArgs map [string ]interface {}
26902719 expectError bool
26912720 expectedSubIssues []* github.Issue
26922721 expectedErrMsg string
2722+ lockdownEnabled bool
26932723 }{
26942724 {
26952725 name : "successful sub-issues listing with minimal parameters" ,
@@ -2729,7 +2759,6 @@ func Test_GetSubIssues(t *testing.T) {
27292759 "page" : float64 (2 ),
27302760 "perPage" : float64 (10 ),
27312761 },
2732- expectError : false ,
27332762 expectedSubIssues : mockSubIssues ,
27342763 },
27352764 {
@@ -2746,9 +2775,29 @@ func Test_GetSubIssues(t *testing.T) {
27462775 "repo" : "repo" ,
27472776 "issue_number" : float64 (42 ),
27482777 },
2749- expectError : false ,
27502778 expectedSubIssues : []* github.Issue {},
27512779 },
2780+ {
2781+ name : "lockdown enabled filters sub-issues without push access" ,
2782+ mockedClient : mock .NewMockedHTTPClient (
2783+ mock .WithRequestMatch (
2784+ mock .GetReposIssuesSubIssuesByOwnerByRepoByIssueNumber ,
2785+ mockSubIssues ,
2786+ ),
2787+ ),
2788+ gqlHTTPClient : newLockdownMockGQLHTTPClient (t , false , map [string ]string {
2789+ "user1" : "WRITE" ,
2790+ "user2" : "READ" ,
2791+ }),
2792+ requestArgs : map [string ]interface {}{
2793+ "method" : "get_sub_issues" ,
2794+ "owner" : "owner" ,
2795+ "repo" : "repo" ,
2796+ "issue_number" : float64 (42 ),
2797+ },
2798+ expectedSubIssues : []* github.Issue {mockSubIssues [0 ]},
2799+ lockdownEnabled : true ,
2800+ },
27522801 {
27532802 name : "parent issue not found" ,
27542803 mockedClient : mock .NewMockedHTTPClient (
@@ -2832,8 +2881,14 @@ func Test_GetSubIssues(t *testing.T) {
28322881 t .Run (tc .name , func (t * testing.T ) {
28332882 // Setup client with mock
28342883 client := github .NewClient (tc .mockedClient )
2835- gqlClient := githubv4 .NewClient (nil )
2836- _ , handler := IssueRead (stubGetClientFn (client ), stubGetGQLClientFn (gqlClient ), translations .NullTranslationHelper , stubFeatureFlags (map [string ]bool {"lockdown-mode" : false }))
2884+ var gqlClient * githubv4.Client
2885+ if tc .gqlHTTPClient != nil {
2886+ gqlClient = githubv4 .NewClient (tc .gqlHTTPClient )
2887+ } else {
2888+ gqlClient = githubv4 .NewClient (nil )
2889+ }
2890+ flags := stubFeatureFlags (map [string ]bool {"lockdown-mode" : tc .lockdownEnabled })
2891+ _ , handler := IssueRead (stubGetClientFn (client ), stubGetGQLClientFn (gqlClient ), translations .NullTranslationHelper , flags )
28372892
28382893 // Create call request
28392894 request := createMCPRequest (tc .requestArgs )
0 commit comments