-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #225. Detect protocol change on socket reuse
- Loading branch information
Showing
5 changed files
with
77 additions
and
4 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
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,63 @@ | ||
import assert from 'assert'; | ||
import { NtlmStateEnum } from '../../../src/models/ntlm.state.enum'; | ||
import { ConnectionContext } from '../../../src/proxy/connection.context'; | ||
|
||
describe('ConnectionContext', () => { | ||
describe('matchHostOrNew', () => { | ||
it('should return true for unused NTLM ', () => { | ||
let context = new ConnectionContext(); | ||
let ntlmHost = new URL('http://localhost:8787'); | ||
let result = context.matchHostOrNew(ntlmHost, false); | ||
assert.equal(result, true); | ||
}); | ||
|
||
it('should return false for used NTLM ', () => { | ||
let context = new ConnectionContext(); | ||
let oldNtlmHost = new URL('http://localhost:8878'); | ||
context.setState(oldNtlmHost, NtlmStateEnum.Authenticated); | ||
let ntlmHost = new URL('http://localhost:8787'); | ||
let result = context.matchHostOrNew(ntlmHost, false); | ||
assert.equal(result, false); | ||
}); | ||
|
||
it('should return true for used NTLM on match', () => { | ||
let context = new ConnectionContext(); | ||
let ntlmHost = new URL('http://localhost:8787'); | ||
context.setState(ntlmHost, NtlmStateEnum.NotAuthenticated); | ||
let result = context.matchHostOrNew(ntlmHost, false); | ||
assert.equal(result, true); | ||
}); | ||
|
||
it('should return false on protocol change http to https for NTLM', () => { | ||
let context = new ConnectionContext(); | ||
let ntlmHost = new URL('localhost:8787'); | ||
context.setState(ntlmHost, NtlmStateEnum.NotAuthenticated); | ||
let result = context.matchHostOrNew(ntlmHost, true); | ||
assert.equal(result, false); | ||
}); | ||
|
||
it('should return false on protocol change https to http for NTLM', () => { | ||
let context = new ConnectionContext(); | ||
let ntlmHost = new URL('localhost:8787'); | ||
context.setState(ntlmHost, NtlmStateEnum.NotAuthenticated); | ||
context.isSSL = true; | ||
let result = context.matchHostOrNew(ntlmHost, false); | ||
assert.equal(result, false); | ||
}); | ||
|
||
it('should return false on protocol change http to https for non NTLM', () => { | ||
let context = new ConnectionContext(); | ||
let newNtlmHost = new URL('https://localhost:8787'); | ||
let result = context.matchHostOrNew(newNtlmHost, true); | ||
assert.equal(result, false); | ||
}); | ||
|
||
it('should return false on protocol change https to http for non NTLM', () => { | ||
let context = new ConnectionContext(); | ||
context.isSSL = true; | ||
let newNtlmHost = new URL('http://localhost:8787'); | ||
let result = context.matchHostOrNew(newNtlmHost, false); | ||
assert.equal(result, false); | ||
}); | ||
}); | ||
}); |