@ -437,15 +437,16 @@ describe('git-auth-helper tests', () => {
}
)
const configureSubmoduleAuth_configures TokenWhenPersistCredentialsTru eAndSshKeyNotSet =
'configureSubmoduleAuth configures token when persist credentials tru e and SSH key not set'
const configureSubmoduleAuth_configures SubmodulesWhenPersistCredentialsFals eAndSshKeyNotSet =
'configureSubmoduleAuth configures submodules when persist credentials fals e and SSH key not set'
it (
configureSubmoduleAuth_configures TokenWhenPersistCredentialsTru eAndSshKeyNotSet,
configureSubmoduleAuth_configures SubmodulesWhenPersistCredentialsFals eAndSshKeyNotSet,
async ( ) = > {
// Arrange
await setup (
configureSubmoduleAuth_configures TokenWhenPersistCredentialsTru eAndSshKeyNotSet
configureSubmoduleAuth_configures SubmodulesWhenPersistCredentialsFals eAndSshKeyNotSet
)
settings . persistCredentials = false
settings . sshKey = ''
const authHelper = gitAuthHelper . createAuthHelper ( git , settings )
await authHelper . configureAuth ( )
@ -456,31 +457,30 @@ describe('git-auth-helper tests', () => {
await authHelper . configureSubmoduleAuth ( )
// Assert
expect ( mockSubmoduleForeach ) . to HaveBeenCalledTimes( 3 )
expect ( mockSubmoduleForeach . mock . calls [ 0 ] [ 0 ] ) . toMatch (
expect ( mockSubmoduleForeach ) . to BeCalledTimes( 1 )
expect ( mockSubmoduleForeach . mock . calls [ 0 ] [ 0 ] as string ) . toMatch (
/unset-all.*insteadOf/
)
expect ( mockSubmoduleForeach . mock . calls [ 1 ] [ 0 ] ) . toMatch ( /http.*extraheader/ )
expect ( mockSubmoduleForeach . mock . calls [ 2 ] [ 0 ] ) . toMatch ( /url.*insteadOf/ )
}
)
const configureSubmoduleAuth_configures TokenWhenPersistCredentialsTru eAndSshKeySet =
'configureSubmoduleAuth configures token when persist credentials tru e and SSH key set'
const configureSubmoduleAuth_configures SubmodulesWhenPersistCredentialsFals eAndSshKeySet =
'configureSubmoduleAuth configures submodules when persist credentials fals e and SSH key set'
it (
configureSubmoduleAuth_configures TokenWhenPersistCredentialsTru eAndSshKeySet,
configureSubmoduleAuth_configures SubmodulesWhenPersistCredentialsFals eAndSshKeySet,
async ( ) = > {
if ( ! sshPath ) {
process . stdout . write (
` Skipped test " ${ configureSubmoduleAuth_configures TokenWhenPersistCredentialsTru eAndSshKeySet} ". Executable 'ssh' not found in the PATH. \ n `
` Skipped test " ${ configureSubmoduleAuth_configures SubmodulesWhenPersistCredentialsFals eAndSshKeySet} ". Executable 'ssh' not found in the PATH. \ n `
)
return
}
// Arrange
await setup (
configureSubmoduleAuth_configures TokenWhenPersistCredentialsTru eAndSshKeySet
configureSubmoduleAuth_configures SubmodulesWhenPersistCredentialsFals eAndSshKeySet
)
settings . persistCredentials = false
const authHelper = gitAuthHelper . createAuthHelper ( git , settings )
await authHelper . configureAuth ( )
const mockSubmoduleForeach = git . submoduleForeach as jest . Mock < any , any >
@ -490,24 +490,23 @@ describe('git-auth-helper tests', () => {
await authHelper . configureSubmoduleAuth ( )
// Assert
expect ( mockSubmoduleForeach ) . toHaveBeenCalledTimes ( 2 )
expect ( mockSubmoduleForeach ) . toHaveBeenCalledTimes ( 1 )
expect ( mockSubmoduleForeach . mock . calls [ 0 ] [ 0 ] ) . toMatch (
/unset-all.*insteadOf/
)
expect ( mockSubmoduleForeach . mock . calls [ 1 ] [ 0 ] ) . toMatch ( /http.*extraheader/ )
}
)
const configureSubmoduleAuth_ doesNotConfigureTokenWhenPersistCredentialsFalse =
'configureSubmoduleAuth does not configure token when persist credentials false '
const configureSubmoduleAuth_ configuresSubmodulesWhenPersistCredentialsTrueAndSshKeyNotSet =
'configureSubmoduleAuth configures submodules when persist credentials true and SSH key not set '
it (
configureSubmoduleAuth_ doesNotConfigureTokenWhenPersistCredentialsFalse ,
configureSubmoduleAuth_ configuresSubmodulesWhenPersistCredentialsTrueAndSshKeyNotSet ,
async ( ) = > {
// Arrange
await setup (
configureSubmoduleAuth_ doesNotConfigureTokenWhenPersistCredentialsFalse
configureSubmoduleAuth_ configuresSubmodulesWhenPersistCredentialsTrueAndSshKeyNotSet
)
settings . persistCredentials = false
settings . sshKey = ''
const authHelper = gitAuthHelper . createAuthHelper ( git , settings )
await authHelper . configureAuth ( )
const mockSubmoduleForeach = git . submoduleForeach as jest . Mock < any , any >
@ -517,28 +516,30 @@ describe('git-auth-helper tests', () => {
await authHelper . configureSubmoduleAuth ( )
// Assert
expect ( mockSubmoduleForeach ) . to BeCalledTimes( 1 )
expect ( mockSubmoduleForeach . mock . calls [ 0 ] [ 0 ] as string ) . toMatch (
expect ( mockSubmoduleForeach ) . to HaveBeenCalledTimes( 3 )
expect ( mockSubmoduleForeach . mock . calls [ 0 ] [ 0 ] ) . toMatch (
/unset-all.*insteadOf/
)
expect ( mockSubmoduleForeach . mock . calls [ 1 ] [ 0 ] ) . toMatch ( /http.*extraheader/ )
expect ( mockSubmoduleForeach . mock . calls [ 2 ] [ 0 ] ) . toMatch ( /url.*insteadOf/ )
}
)
const configureSubmoduleAuth_ doesNotConfigureUrlInsteadOf WhenPersistCredentialsTrueAndSshKeySet =
'configureSubmoduleAuth does not configure URL insteadOf when persist credentials true and SSH key set'
const configureSubmoduleAuth_ configuresSubmodules WhenPersistCredentialsTrueAndSshKeySet =
'configureSubmoduleAuth configures submodules when persist credentials true and SSH key set'
it (
configureSubmoduleAuth_ doesNotConfigureUrlInsteadOf WhenPersistCredentialsTrueAndSshKeySet,
configureSubmoduleAuth_ configuresSubmodules WhenPersistCredentialsTrueAndSshKeySet,
async ( ) = > {
if ( ! sshPath ) {
process . stdout . write (
` Skipped test " ${ configureSubmoduleAuth_ doesNotConfigureUrlInsteadOf WhenPersistCredentialsTrueAndSshKeySet} ". Executable 'ssh' not found in the PATH. \ n `
` Skipped test " ${ configureSubmoduleAuth_ configuresSubmodules WhenPersistCredentialsTrueAndSshKeySet} ". Executable 'ssh' not found in the PATH. \ n `
)
return
}
// Arrange
await setup (
configureSubmoduleAuth_ doesNotConfigureUrlInsteadOf WhenPersistCredentialsTrueAndSshKeySet
configureSubmoduleAuth_ configuresSubmodules WhenPersistCredentialsTrueAndSshKeySet
)
const authHelper = gitAuthHelper . createAuthHelper ( git , settings )
await authHelper . configureAuth ( )
@ -549,37 +550,12 @@ describe('git-auth-helper tests', () => {
await authHelper . configureSubmoduleAuth ( )
// Assert
expect ( mockSubmoduleForeach ) . toHaveBeenCalledTimes ( 2 )
expect ( mockSubmoduleForeach ) . toHaveBeenCalledTimes ( 3 )
expect ( mockSubmoduleForeach . mock . calls [ 0 ] [ 0 ] ) . toMatch (
/unset-all.*insteadOf/
)
expect ( mockSubmoduleForeach . mock . calls [ 1 ] [ 0 ] ) . toMatch ( /http.*extraheader/ )
}
)
const configureSubmoduleAuth_removesUrlInsteadOfWhenPersistCredentialsFalse =
'configureSubmoduleAuth removes URL insteadOf when persist credentials false'
it (
configureSubmoduleAuth_removesUrlInsteadOfWhenPersistCredentialsFalse ,
async ( ) = > {
// Arrange
await setup (
configureSubmoduleAuth_removesUrlInsteadOfWhenPersistCredentialsFalse
)
settings . persistCredentials = false
const authHelper = gitAuthHelper . createAuthHelper ( git , settings )
await authHelper . configureAuth ( )
const mockSubmoduleForeach = git . submoduleForeach as jest . Mock < any , any >
mockSubmoduleForeach . mockClear ( ) // reset calls
// Act
await authHelper . configureSubmoduleAuth ( )
// Assert
expect ( mockSubmoduleForeach ) . toBeCalledTimes ( 1 )
expect ( mockSubmoduleForeach . mock . calls [ 0 ] [ 0 ] as string ) . toMatch (
/unset-all.*insteadOf/
)
expect ( mockSubmoduleForeach . mock . calls [ 2 ] [ 0 ] ) . toMatch ( /core\.sshCommand/ )
}
)