Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from bjowes/develop
Release 0.7.0
- Loading branch information
Showing
15 changed files
with
1,350 additions
and
201 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,25 @@ | ||
/// <reference types="cypress" /> | ||
|
||
declare namespace Cypress { | ||
interface Chainable<Subject> { | ||
/** | ||
* Adds NTLM authentication support to Cypress for a specific host. | ||
* You can call this multiple times to register several hosts or | ||
* change credentials. | ||
* @example | ||
```js | ||
cy.ntlm('https://ntlm.acme.com', 'TheUser', 'ThePassword', 'TheDomain'); | ||
``` | ||
*/ | ||
ntlm(ntlmHost: string, username: string, password: string, domain?: string, workstation?: string): Chainable<any> | ||
|
||
/** | ||
* Reset NTLM authentication for all configured hosts. Recommended before/after tests. | ||
* @example | ||
```js | ||
cy.ntlmReset(); | ||
``` | ||
*/ | ||
ntlmReset(): Chainable<any> | ||
} | ||
} |
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
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,64 @@ | ||
|
||
const url = require('url'); | ||
|
||
module.exports = { | ||
validate: function(config) { | ||
if (!config.ntlmHost || | ||
!config.username || | ||
!config.password) { | ||
return { ok: false, message: 'Incomplete configuration. ntlmHost, username and password are required fields.' }; | ||
} | ||
|
||
let urlTest = url.parse(config.ntlmHost); | ||
if (!urlTest.hostname || !urlTest.protocol || !urlTest.slashes) { | ||
return { ok: false, message: 'Invalid ntlmHost, must be a valid URL (like https://www.google.com)' }; | ||
} | ||
if (urlTest.path && urlTest.path !== '' && urlTest.path !== '/') { | ||
return { ok: false, message: 'Invalid ntlmHost, must not contain any path or query (https://www.google.com is ok, https://www.google.com/search is not ok)' }; | ||
} | ||
|
||
if (!validateUsername(config.username)) { | ||
return { ok: false, message: 'Username contains invalid characters or is too long.' }; | ||
} | ||
|
||
if (config.domain && !validateDomainOrWorkstation(config.domain)) { | ||
return { ok: false, message: 'Domain contains invalid characters or is too long.' }; | ||
} | ||
|
||
if (config.workstation && !validateDomainOrWorkstation(config.workstation)) { | ||
return { ok: false, message: 'Workstation contains invalid characters or is too long.' }; | ||
} | ||
|
||
return { ok: true }; | ||
} | ||
}; | ||
|
||
// https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/bb726984(v=technet.10) | ||
// Max 104 chars, invalid chars: " / \ [ ] : ; | = , + * ? < > | ||
function validateUsername(username) { | ||
if (username.length > 104) { | ||
return false; | ||
} | ||
if (username.includes('"') || username.includes('/') || username.includes('\\') || | ||
username.includes('[') || username.includes(']') || username.includes(':') || | ||
username.includes(';') || username.includes('|') || username.includes('=') || | ||
username.includes(',') || username.includes('+') || username.includes('*') || | ||
username.includes('?') || username.includes('<') || username.includes('>')) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
// https://support.microsoft.com/sv-se/help/909264/naming-conventions-in-active-directory-for-computers-domains-sites-and | ||
// Max 15 chars, invalid chars: " / \ : | * ? < > | ||
function validateDomainOrWorkstation(domain) { | ||
if (domain.length > 15) { | ||
return false; | ||
} | ||
if (domain.includes('"') || domain.includes('/') || domain.includes('\\') || | ||
domain.includes(':') || domain.includes('|') || domain.includes('*') || | ||
domain.includes('?') || domain.includes('<') || domain.includes('>')) { | ||
return false; | ||
} | ||
return true; | ||
} |
Oops, something went wrong.