Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
feat(serenity-bdd): support for internal repositories that require au…
…thentication If you're downloading the Serenity BDD reporter jar from an internal repositorythat requires authentication, use the following command: `serenity-bdd update --repository https://mycompany.com/repo --auth <username>:<password> --ignoreSSL`
- Loading branch information
Showing
5 changed files
with
85 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'mocha'; | ||
|
||
import { expect } from '@integration/testing-tools'; | ||
import { Path } from '@serenity-js/core/lib/io'; | ||
|
||
import { Credentials, GAV } from '../../../src/cli/model'; | ||
|
||
describe('Credentials', () => { | ||
|
||
it('defaults to "no credentials" if the credentials are not specified', () => { | ||
const credentials = Credentials.fromString(undefined); | ||
|
||
expect(credentials.username).to.equal(undefined); | ||
expect(credentials.password).to.equal(undefined); | ||
}); | ||
|
||
it('defaults to "no credentials" if the credentials are empty', () => { | ||
const credentials = Credentials.fromString(''); | ||
|
||
expect(credentials.username).to.equal(undefined); | ||
expect(credentials.password).to.equal(undefined); | ||
}); | ||
|
||
it('complains if the credentials string does not follow the <username>:<password> template', () => { | ||
|
||
expect(() => Credentials.fromString('invalid')) | ||
.to.throw(Error, 'Credentials should follow the "<username>:<password>" format') | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ensure, Predicate, TinyType } from 'tiny-types'; | ||
|
||
/** | ||
* @package | ||
*/ | ||
export class Credentials extends TinyType { | ||
|
||
static fromString(value: string): Credentials { | ||
if (! value) { | ||
return new Credentials(undefined, undefined); | ||
} | ||
|
||
ensure('Credentials', value, matches(/(.*):(.*)/, `follow the "<username>:<password>" format`)); | ||
|
||
const index = value.indexOf(':'); | ||
|
||
return new Credentials( | ||
value.substring(0, index), | ||
value.substring(index + 1) | ||
) | ||
} | ||
|
||
constructor( | ||
public readonly username: string, | ||
public readonly password: string, | ||
) { | ||
super(); | ||
} | ||
} | ||
|
||
/** | ||
* @package | ||
*/ | ||
function matches(expression: RegExp, description?: string): Predicate<string> { | ||
return Predicate.to(description || `match pattern ${ expression }`, (value: string) => expression.test(value)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters