@@ -1214,19 +1214,45 @@ func Test_validateGHSAID(t *testing.T) {
12141214}
12151215
12161216func TestSecurityAdvisoryWriteToolsRegistered (t * testing.T ) {
1217- expected := map [string ]bool {
1218- "create_repository_security_advisory" : false ,
1219- "update_repository_security_advisory" : false ,
1220- "request_cve_for_repository_security_advisory" : false ,
1217+ expected := map [string ]struct {
1218+ readOnly bool
1219+ destructive bool
1220+ openWorld bool
1221+ }{
1222+ "create_repository_security_advisory" : {
1223+ readOnly : false ,
1224+ destructive : true ,
1225+ openWorld : true ,
1226+ },
1227+ "update_repository_security_advisory" : {
1228+ readOnly : false ,
1229+ destructive : true ,
1230+ openWorld : true ,
1231+ },
1232+ "request_cve_for_repository_security_advisory" : {
1233+ readOnly : false ,
1234+ destructive : false ,
1235+ openWorld : true ,
1236+ },
12211237 }
12221238
12231239 for _ , tool := range AllTools (translations .NullTranslationHelper ) {
1224- if _ , ok := expected [tool .Tool .Name ]; ok {
1225- assert .Equal (t , ToolsetMetadataSecurityAdvisories .ID , tool .Toolset .ID )
1226- require .NotNil (t , tool .Tool .Annotations )
1227- assert .Equal (t , expected [tool .Tool .Name ], tool .Tool .Annotations .ReadOnlyHint )
1228- delete (expected , tool .Tool .Name )
1240+ want , ok := expected [tool .Tool .Name ]
1241+ if ! ok {
1242+ continue
1243+ }
1244+ assert .Equal (t , ToolsetMetadataSecurityAdvisories .ID , tool .Toolset .ID )
1245+ require .NotNil (t , tool .Tool .Annotations )
1246+ assert .Equal (t , want .readOnly , tool .Tool .Annotations .ReadOnlyHint )
1247+ require .NotNil (t , tool .Tool .Annotations .OpenWorldHint )
1248+ assert .Equal (t , want .openWorld , * tool .Tool .Annotations .OpenWorldHint )
1249+ if want .destructive {
1250+ require .NotNil (t , tool .Tool .Annotations .DestructiveHint )
1251+ assert .True (t , * tool .Tool .Annotations .DestructiveHint )
1252+ } else {
1253+ assert .Nil (t , tool .Tool .Annotations .DestructiveHint )
12291254 }
1255+ delete (expected , tool .Tool .Name )
12301256 }
12311257
12321258 assert .Empty (t , expected , "missing security advisory write tools: %v" , expected )
0 commit comments