MCPcopy Create free account
hub / github.com/github/gh-aw / TestPermissionCombinations

Function TestPermissionCombinations

pkg/workflow/permissions_enum_test.go:419–466  ·  view source on GitHub ↗

TestPermissionCombinations tests various permission combinations

(t *testing.T)

Source from the content-addressed store, hash-verified

417
418// TestPermissionCombinations tests various permission combinations
419func TestPermissionCombinations(t *testing.T) {
420 tests := []struct {
421 name string
422 permissions string
423 expectValid bool
424 description string
425 }{
426 {
427 name: "multiple read permissions",
428 permissions: `permissions:
429 contents: read
430 issues: read
431 pull-requests: read`,
432 expectValid: true,
433 description: "multiple read permissions are valid",
434 },
435 {
436 name: "mixed read and write permissions",
437 permissions: `permissions:
438 contents: read
439 issues: write
440 pull-requests: write`,
441 expectValid: true,
442 description: "mixing read and write is valid",
443 },
444 {
445 name: "all scopes with none",
446 permissions: `permissions:
447 contents: none
448 issues: none
449 pull-requests: none`,
450 expectValid: true,
451 description: "all none is valid (explicit deny)",
452 },
453 }
454
455 for _, tt := range tests {
456 t.Run(tt.name, func(t *testing.T) {
457 parser := NewPermissionsParser(tt.permissions)
458
459 if tt.expectValid {
460 if len(parser.parsedPerms) == 0 && !parser.isShorthand {
461 t.Errorf("%s: expected permissions to be parsed", tt.description)
462 }
463 }
464 })
465 }
466}
467
468// TestPermissionsWhitespaceHandling tests whitespace handling in permissions
469func TestPermissionsWhitespaceHandling(t *testing.T) {

Callers

nothing calls this directly

Calls 3

NewPermissionsParserFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected