mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-04 06:41:56 +02:00 
			
		
		
		
	Adding tests for injecting the GitHub URL
This commit is contained in:
		
							parent
							
								
									385d3aa94f
								
							
						
					
					
						commit
						092f9bd613
					
				
					 1 changed files with 35 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -20,6 +20,7 @@ let tempHomedir: string
 | 
			
		|||
let git: IGitCommandManager & { env: { [key: string]: string } }
 | 
			
		||||
let settings: IGitSourceSettings
 | 
			
		||||
let sshPath: string
 | 
			
		||||
let githubServerUrl: string
 | 
			
		||||
 | 
			
		||||
describe('git-auth-helper tests', () => {
 | 
			
		||||
  beforeAll(async () => {
 | 
			
		||||
| 
						 | 
				
			
			@ -67,11 +68,15 @@ describe('git-auth-helper tests', () => {
 | 
			
		|||
    }
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const configureAuth_configuresAuthHeader =
 | 
			
		||||
    'configureAuth configures auth header'
 | 
			
		||||
  it(configureAuth_configuresAuthHeader, async () => {
 | 
			
		||||
  async function testAuthHeader(testName: string, serverUrl: string | undefined = undefined) {
 | 
			
		||||
    // Arrange
 | 
			
		||||
    await setup(configureAuth_configuresAuthHeader)
 | 
			
		||||
    let expectedServerUrl = 'https://github.com'
 | 
			
		||||
    if (serverUrl) {
 | 
			
		||||
      githubServerUrl = serverUrl
 | 
			
		||||
      expectedServerUrl = githubServerUrl
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    await setup(testName)
 | 
			
		||||
    expect(settings.authToken).toBeTruthy() // sanity check
 | 
			
		||||
    const authHelper = gitAuthHelper.createAuthHelper(git, settings)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -88,9 +93,25 @@ describe('git-auth-helper tests', () => {
 | 
			
		|||
    ).toString('base64')
 | 
			
		||||
    expect(
 | 
			
		||||
      configContent.indexOf(
 | 
			
		||||
        `http.https://github.com/.extraheader AUTHORIZATION: basic ${basicCredential}`
 | 
			
		||||
        `http.${expectedServerUrl}/.extraheader AUTHORIZATION: basic ${basicCredential}`
 | 
			
		||||
      )
 | 
			
		||||
    ).toBeGreaterThanOrEqual(0)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const configureAuth_configuresAuthHeader =
 | 
			
		||||
    'configureAuth configures auth header'
 | 
			
		||||
  it(configureAuth_configuresAuthHeader, async () => {
 | 
			
		||||
    await testAuthHeader(configureAuth_configuresAuthHeader);
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const configureAuth_AcceptsGitHubServerUrl = 'inject https://my-ghes-server.com as github server url'
 | 
			
		||||
  it(configureAuth_AcceptsGitHubServerUrl, async () => {
 | 
			
		||||
    await testAuthHeader(configureAuth_AcceptsGitHubServerUrl, 'https://my-ghes-server.com');
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const configureAuth_AcceptsGitHubServerUrlSetToGHEC = 'inject https://github.com as github server url'
 | 
			
		||||
  it(configureAuth_AcceptsGitHubServerUrlSetToGHEC, async () => {
 | 
			
		||||
    await testAuthHeader(configureAuth_AcceptsGitHubServerUrl, 'https://github.com');
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const configureAuth_configuresAuthHeaderEvenWhenPersistCredentialsFalse =
 | 
			
		||||
| 
						 | 
				
			
			@ -779,7 +800,7 @@ async function setup(testName: string): Promise<void> {
 | 
			
		|||
    sshStrict: true,
 | 
			
		||||
    workflowOrganizationId: 123456,
 | 
			
		||||
    setSafeDirectory: true,
 | 
			
		||||
    githubServerUrl: undefined
 | 
			
		||||
    githubServerUrl: githubServerUrl
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue