Skip to content

PR #12

PR #12 #49

GitHub Actions / Jest Tests succeeded Jul 21, 2025 in 0s

110 passed, 0 failed and 0 skipped

Tests passed successfully

✅ create-github-app-token/test-results/junit.xml

110 tests were completed in 8s with 110 passed, 0 failed and 0 skipped.

Test suite Passed Failed Skipped Time
test/core/github-service.test.ts 34✅ 7s
test/core/proxy-config.test.ts 12✅ 418ms
test/tasks/post.test.ts 12✅ 7s
test/tasks/run.test.ts 28✅ 7s
test/utils/constants.test.ts 9✅ 310ms
test/utils/github.test.ts 4✅ 254ms
test/utils/validation.test.ts 11✅ 317ms

✅ test/core/github-service.test.ts

GitHubService › constructor
  ✅ should create GitHubService with base URL
  ✅ should throw error when base URL is not provided
  ✅ should normalize base URL by removing trailing slash
  ✅ should create service with proxy configuration
GitHubService › generateJWT
  ✅ should generate JWT with correct payload
GitHubService › getInstallationId › organization installation
  ✅ should get installation ID for organization
  ✅ should handle 404 error for organization installation
GitHubService › getInstallationId › user installation
  ✅ should get installation ID for user
  ✅ should handle 404 error for user installation
GitHubService › getInstallationId › repository installation
  ✅ should get installation ID for repository
  ✅ should reject invalid repository names
  ✅ should handle 404 error for repository installation
GitHubService › getInstallationId
  ✅ should handle generic errors
GitHubService › getInstallationToken
  ✅ should create installation token without repositories
  ✅ should create installation token with repositories
  ✅ should create installation token with permissions
  ✅ should create installation token with repositories and permissions
  ✅ should handle 404 error for installation token
  ✅ should handle 422 error for invalid permissions
  ✅ should handle 422 error for invalid repositories
  ✅ should handle generic HTTP errors
  ✅ should handle 403 forbidden error
  ✅ should handle network errors
GitHubService › revokeInstallationToken
  ✅ should successfully revoke installation token
  ✅ should handle errors when revoking token and return false
  ✅ should handle network errors when revoking token
  ✅ should handle revoke token with different HTTP status codes
GitHubService › authorization headers
  ✅ should include Bearer token in authorization header
GitHubService › advanced integration scenarios
  ✅ should handle enterprise GitHub URL normalization
  ✅ should handle multiple repository installations
  ✅ should handle permission downgrading correctly
  ✅ should handle rate limiting headers in debug mode
  ✅ should handle installation response without optional fields
  ✅ should handle installation response with selected repositories

✅ test/core/proxy-config.test.ts

ProxyConfig › constructor
  ✅ should create ProxyConfig with empty options
  ✅ should create ProxyConfig with proxy URL only
  ✅ should create ProxyConfig with all options
ProxyConfig › fromAzurePipelines
  ✅ should return undefined when no proxy configuration exists
  ✅ should create ProxyConfig from Azure Pipelines configuration
  ✅ should create ProxyConfig without username
ProxyConfig › hasProxyConfiguration
  ✅ should return false when no proxy URL is set
  ✅ should return true when proxy URL is set
ProxyConfig › getProxyAgent
  ✅ should return undefined when no proxy URL is configured
  ✅ should return HTTP proxy agent for HTTP proxy URL
  ✅ should return HTTPS proxy agent for HTTPS proxy URL
  ✅ should configure proxy agent with authentication

✅ test/tasks/post.test.ts

post task logic › task variable processing
  ✅ should process task variables correctly
  ✅ should handle custom base URL from task variables
post task logic › skip scenarios
  ✅ should skip revocation when skipTokenRevoke is true
  ✅ should skip revocation when no installation token is found
  ✅ should perform revocation when conditions are met
post task logic › Post Logic
  ✅ should create GitHub service with correct parameters and revoke token successfully
  ✅ should handle token revocation failure without failing the task
  ✅ should handle service creation with custom base URL
  ✅ should handle exceptions during token revocation gracefully
post task logic › error handling scenarios
  ✅ should handle missing task variables gracefully
post task logic › proxy integration
  ✅ should pass proxy configuration to GitHub service when available
  ✅ should handle when no proxy configuration is available

✅ test/tasks/run.test.ts

run task logic › successful execution scenarios
  ✅ should complete successfully with service connection
  ✅ should complete successfully with direct certificate input
  ✅ should complete successfully with certificate file
  ✅ should auto-extract owner from repository name when using GitHub provider
  ✅ should handle repositories list correctly
  ✅ should handle permissions correctly
run task logic › validation scenarios
  ✅ should fail when no private key is provided
  ✅ should fail when no app client ID is provided
  ✅ should fail when owner is not provided and repository provider is not GitHub
  ✅ should fail when certificate file does not exist
  ✅ should fail when permissions JSON is invalid
  ✅ should fail when invalid account type is provided
  ✅ should fail when permissions is not an object
  ✅ should fail when permissions is null
  ✅ should skip account type validation when repositories list is provided
run task logic › service connection features
  ✅ should handle permissions override from service connection
  ✅ should handle forceRepoScope from service connection
  ✅ should handle custom base URL from service connection
  ✅ should fail when forceRepoScope is used with non-GitHub provider
  ✅ should handle forceRepoScope with different repositories warning
  ✅ should handle forceRepoScope with no repositories warning
run task logic › error handling during execution
  ✅ should handle JWT generation failure
  ✅ should handle installation ID retrieval failure
  ✅ should handle installation token creation failure
  ✅ should handle service connection not found
  ✅ should handle invalid service connection permissions JSON
  ✅ should handle invalid repository names during installation ID retrieval
  ✅ should handle service connection with invalid permissions object type

✅ test/utils/constants.test.ts

constants › API constants
  ✅ should define default API URL
  ✅ should define JWT expiration as 10 minutes in seconds
constants › output variable names
  ✅ should define installation ID output variable name
  ✅ should define installation token output variable name
  ✅ should define token expiration output variable name
constants › task variable names
  ✅ should define skip token task variable name
  ✅ should define base URL task variable name
constants › account type constants
  ✅ should define user account type
  ✅ should define organization account type

✅ test/utils/github.test.ts

github utilities › getRepoName
  ✅ should extract repository name from owner/repo format
  ✅ should handle repository names with special characters
github utilities › getOwnerName
  ✅ should extract owner name from owner/repo format
  ✅ should handle owner names with special characters

✅ test/utils/validation.test.ts

validation utilities › validateRepositoryName
  ✅ should accept valid repository names with letters and numbers
  ✅ should accept repository names with dots, dashes, and underscores
  ✅ should accept repository names starting with dots, dashes, or underscores
  ✅ should reject repository names with invalid characters
  ✅ should reject empty repository names
  ✅ should reject repository names with Unicode characters
validation utilities › validateAccountType
  ✅ should accept valid account types
  ✅ should reject invalid account types
  ✅ should be case sensitive
validation utilities › Error message consistency
  ✅ should provide consistent error format for invalid account type
  ✅ should provide detailed repository validation error