@@ -297,10 +297,6 @@ func Test_IssueRead_IFC_InsidersMode(t *testing.T) {
297297 handlers := map [string ]http.HandlerFunc {
298298 GetReposIssuesByOwnerByRepoByIssueNumber : mockResponse (t , http .StatusOK , mockIssue ),
299299 GetReposIssuesCommentsByOwnerByRepoByIssueNumber : mockResponse (t , http .StatusOK , mockComments ),
300- GetReposCollaboratorsByOwnerByRepo : mockResponse (t , http .StatusOK , []* github.User {
301- {Login : github .Ptr ("octocat" )},
302- {Login : github .Ptr ("alice" )},
303- }),
304300 }
305301 if repoStatus != 0 && repoStatus != http .StatusOK {
306302 handlers [GetReposByOwnerByRepo ] = mockResponse (t , repoStatus , "boom" )
@@ -356,7 +352,7 @@ func Test_IssueRead_IFC_InsidersMode(t *testing.T) {
356352 require .NotNil (t , result .Meta )
357353 ifcMap := unmarshalIFC (t , result .Meta ["ifc" ])
358354 assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
359- assert .Equal (t , [] any { "public" } , ifcMap ["confidentiality" ])
355+ assert .Equal (t , "public" , ifcMap ["confidentiality" ])
360356 })
361357
362358 t .Run ("insiders mode enabled on private repo with get_comments emits private untrusted" , func (t * testing.T ) {
@@ -374,7 +370,7 @@ func Test_IssueRead_IFC_InsidersMode(t *testing.T) {
374370 require .NotNil (t , result .Meta )
375371 ifcMap := unmarshalIFC (t , result .Meta ["ifc" ])
376372 assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
377- assert .Equal (t , [] any { "octocat" , "alice" } , ifcMap ["confidentiality" ])
373+ assert .Equal (t , "private" , ifcMap ["confidentiality" ])
378374 })
379375
380376 t .Run ("insiders mode skips ifc label when visibility lookup fails" , func (t * testing.T ) {
@@ -829,23 +825,17 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
829825 }
830826
831827 type repoFixture struct {
832- owner string
833- repo string
834- isPrivate bool
835- collaborators []string
836- repoStatus int
837- collaboratorsStatus int
828+ owner string
829+ repo string
830+ isPrivate bool
831+ repoStatus int
838832 }
839833
840834 repoHandlers := func (repos []repoFixture ) map [string ]http.HandlerFunc {
841835 repoByPath := map [string ]repoFixture {}
842836 for _ , r := range repos {
843837 repoByPath ["/repos/" + r .owner + "/" + r .repo ] = r
844838 }
845- collaboratorsByPath := map [string ]repoFixture {}
846- for _ , r := range repos {
847- collaboratorsByPath ["/repos/" + r .owner + "/" + r .repo + "/collaborators" ] = r
848- }
849839 return map [string ]http.HandlerFunc {
850840 GetReposByOwnerByRepo : func (w http.ResponseWriter , req * http.Request ) {
851841 r , ok := repoByPath [req .URL .Path ]
@@ -864,25 +854,6 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
864854 w .WriteHeader (http .StatusOK )
865855 _ , _ = w .Write (body )
866856 },
867- GetReposCollaboratorsByOwnerByRepo : func (w http.ResponseWriter , req * http.Request ) {
868- r , ok := collaboratorsByPath [req .URL .Path ]
869- if ! ok {
870- w .WriteHeader (http .StatusOK )
871- _ , _ = w .Write ([]byte ("[]" ))
872- return
873- }
874- if r .collaboratorsStatus != 0 && r .collaboratorsStatus != http .StatusOK {
875- w .WriteHeader (r .collaboratorsStatus )
876- return
877- }
878- users := make ([]* github.User , len (r .collaborators ))
879- for i , login := range r .collaborators {
880- users [i ] = & github.User {Login : github .Ptr (login )}
881- }
882- body , _ := json .Marshal (users )
883- w .WriteHeader (http .StatusOK )
884- _ , _ = w .Write (body )
885- },
886857 }
887858 }
888859
@@ -909,7 +880,7 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
909880 assert .Nil (t , result .Meta )
910881 })
911882
912- t .Run ("insiders mode enabled with single public repo emits public untrusted" , func (t * testing.T ) {
883+ t .Run ("insiders mode all public emits public untrusted" , func (t * testing.T ) {
913884 searchResult := & github.IssuesSearchResult {Issues : []* github.Issue {makeIssue ("octocat" , "public-repo" , 1 )}}
914885 deps := BaseDeps {
915886 Client : github .NewClient (makeMockClient (searchResult , []repoFixture {{owner : "octocat" , repo : "public-repo" }})),
@@ -925,17 +896,17 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
925896 require .NotNil (t , result .Meta )
926897 ifcMap := unmarshalIFC (t , result .Meta ["ifc" ])
927898 assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
928- assert .Equal (t , [] any { "public" } , ifcMap ["confidentiality" ])
899+ assert .Equal (t , "public" , ifcMap ["confidentiality" ])
929900 })
930901
931- t .Run ("insiders mode mixed public and private keeps the private readers " , func (t * testing.T ) {
902+ t .Run ("insiders mode mixed public and private emits private untrusted " , func (t * testing.T ) {
932903 searchResult := & github.IssuesSearchResult {Issues : []* github.Issue {
933904 makeIssue ("octocat" , "private-repo" , 1 ),
934905 makeIssue ("octocat" , "public-repo" , 2 ),
935906 }}
936907 deps := BaseDeps {
937908 Client : github .NewClient (makeMockClient (searchResult , []repoFixture {
938- {owner : "octocat" , repo : "private-repo" , isPrivate : true , collaborators : [] string { "alice" } },
909+ {owner : "octocat" , repo : "private-repo" , isPrivate : true },
939910 {owner : "octocat" , repo : "public-repo" },
940911 })),
941912 Flags : FeatureFlags {InsidersMode : true },
@@ -950,32 +921,7 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
950921 require .NotNil (t , result .Meta )
951922 ifcMap := unmarshalIFC (t , result .Meta ["ifc" ])
952923 assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
953- assert .Equal (t , []any {"alice" }, ifcMap ["confidentiality" ])
954- })
955-
956- t .Run ("insiders mode two private repos intersect collaborators" , func (t * testing.T ) {
957- searchResult := & github.IssuesSearchResult {Issues : []* github.Issue {
958- makeIssue ("octocat" , "repo-a" , 1 ),
959- makeIssue ("octocat" , "repo-b" , 2 ),
960- }}
961- deps := BaseDeps {
962- Client : github .NewClient (makeMockClient (searchResult , []repoFixture {
963- {owner : "octocat" , repo : "repo-a" , isPrivate : true , collaborators : []string {"alice" , "bob" , "carol" }},
964- {owner : "octocat" , repo : "repo-b" , isPrivate : true , collaborators : []string {"bob" , "carol" , "dan" }},
965- })),
966- Flags : FeatureFlags {InsidersMode : true },
967- }
968- handler := serverTool .Handler (deps )
969-
970- request := createMCPRequest (reqParams )
971- result , err := handler (ContextWithDeps (context .Background (), deps ), & request )
972- require .NoError (t , err )
973- require .False (t , result .IsError )
974-
975- require .NotNil (t , result .Meta )
976- ifcMap := unmarshalIFC (t , result .Meta ["ifc" ])
977- assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
978- assert .Equal (t , []any {"bob" , "carol" }, ifcMap ["confidentiality" ])
924+ assert .Equal (t , "private" , ifcMap ["confidentiality" ])
979925 })
980926
981927 t .Run ("insiders mode skips ifc label when visibility lookup fails" , func (t * testing.T ) {
@@ -999,27 +945,6 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
999945 }
1000946 })
1001947
1002- t .Run ("insiders mode skips ifc label when collaborators lookup fails" , func (t * testing.T ) {
1003- searchResult := & github.IssuesSearchResult {Issues : []* github.Issue {makeIssue ("octocat" , "private-repo" , 1 )}}
1004- deps := BaseDeps {
1005- Client : github .NewClient (makeMockClient (searchResult , []repoFixture {
1006- {owner : "octocat" , repo : "private-repo" , isPrivate : true , collaboratorsStatus : http .StatusInternalServerError },
1007- })),
1008- Flags : FeatureFlags {InsidersMode : true },
1009- }
1010- handler := serverTool .Handler (deps )
1011-
1012- request := createMCPRequest (reqParams )
1013- result , err := handler (ContextWithDeps (context .Background (), deps ), & request )
1014- require .NoError (t , err )
1015- require .False (t , result .IsError , "tool call should still succeed when collaborators lookup fails" )
1016-
1017- if result .Meta != nil {
1018- _ , hasIFC := result .Meta ["ifc" ]
1019- assert .False (t , hasIFC , "ifc label should be omitted when collaborators lookup fails" )
1020- }
1021- })
1022-
1023948 t .Run ("insiders mode empty results emits public untrusted" , func (t * testing.T ) {
1024949 searchResult := & github.IssuesSearchResult {Issues : []* github.Issue {}}
1025950 deps := BaseDeps {
@@ -1036,7 +961,7 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
1036961 require .NotNil (t , result .Meta )
1037962 ifcMap := unmarshalIFC (t , result .Meta ["ifc" ])
1038963 assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
1039- assert .Equal (t , [] any { "public" } , ifcMap ["confidentiality" ])
964+ assert .Equal (t , "public" , ifcMap ["confidentiality" ])
1040965 })
1041966}
1042967
@@ -1804,24 +1729,13 @@ func Test_ListIssues_IFC_InsidersMode(t *testing.T) {
18041729 require .NoError (t , json .Unmarshal (ifcJSON , & ifcMap ))
18051730
18061731 assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
1807- confList , ok := ifcMap ["confidentiality" ].([]any )
1808- require .True (t , ok , "confidentiality should be a list" )
1809- require .Len (t , confList , 1 )
1810- assert .Equal (t , "public" , confList [0 ])
1732+ assert .Equal (t , "public" , ifcMap ["confidentiality" ])
18111733 })
18121734
1813- t .Run ("insiders mode enabled on private repo emits private untrusted label with collaborators " , func (t * testing.T ) {
1735+ t .Run ("insiders mode enabled on private repo emits private untrusted label" , func (t * testing.T ) {
18141736 matcher := githubv4mock .NewQueryMatcher (query , vars , makeResponse (true ))
18151737 gqlClient := githubv4 .NewClient (githubv4mock .NewMockedHTTPClient (matcher ))
1816- restClient := github .NewClient (MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
1817- GetReposCollaboratorsByOwnerByRepo : mockResponse (t , http .StatusOK , []* github.User {
1818- {Login : github .Ptr ("octocat" )},
1819- {Login : github .Ptr ("alice" )},
1820- {Login : github .Ptr ("bob" )},
1821- }),
1822- }))
18231738 deps := BaseDeps {
1824- Client : restClient ,
18251739 GQLClient : gqlClient ,
18261740 Flags : FeatureFlags {InsidersMode : true },
18271741 }
@@ -1842,36 +1756,7 @@ func Test_ListIssues_IFC_InsidersMode(t *testing.T) {
18421756 require .NoError (t , json .Unmarshal (ifcJSON , & ifcMap ))
18431757
18441758 assert .Equal (t , "untrusted" , ifcMap ["integrity" ])
1845- confList , ok := ifcMap ["confidentiality" ].([]any )
1846- require .True (t , ok , "confidentiality should be a list" )
1847- assert .Equal (t , []any {"octocat" , "alice" , "bob" }, confList )
1848- })
1849-
1850- t .Run ("insiders mode enabled on private repo falls back to owner when collaborators lookup fails" , func (t * testing.T ) {
1851- matcher := githubv4mock .NewQueryMatcher (query , vars , makeResponse (true ))
1852- gqlClient := githubv4 .NewClient (githubv4mock .NewMockedHTTPClient (matcher ))
1853- restClient := github .NewClient (MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
1854- GetReposCollaboratorsByOwnerByRepo : mockResponse (t , http .StatusInternalServerError , "boom" ),
1855- }))
1856- deps := BaseDeps {
1857- Client : restClient ,
1858- GQLClient : gqlClient ,
1859- Flags : FeatureFlags {InsidersMode : true },
1860- }
1861- handler := serverTool .Handler (deps )
1862-
1863- request := createMCPRequest (reqParams )
1864- result , err := handler (ContextWithDeps (context .Background (), deps ), & request )
1865- require .NoError (t , err )
1866- require .False (t , result .IsError )
1867-
1868- require .NotNil (t , result .Meta )
1869- ifcJSON , err := json .Marshal (result .Meta ["ifc" ])
1870- require .NoError (t , err )
1871- var ifcMap map [string ]any
1872- require .NoError (t , json .Unmarshal (ifcJSON , & ifcMap ))
1873-
1874- assert .Equal (t , []any {"octocat" }, ifcMap ["confidentiality" ])
1759+ assert .Equal (t , "private" , ifcMap ["confidentiality" ])
18751760 })
18761761}
18771762
0 commit comments