-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AG-26073 check trusted urls by hostnames
Merge in ADGUARD-FILTERS/tsurlfilter from fix/AG-26073 to master Squashed commit of the following: commit 5ad3c8b Author: Maxim Topciu <mtopciu@adguard.com> Date: Fri Sep 22 13:54:28 2023 +0300 AG-26073 add changelog commit cf3ee38 Author: Maxim Topciu <mtopciu@adguard.com> Date: Fri Sep 22 13:52:28 2023 +0300 AG-26073 check trusted urls by hostnames
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 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
41 changes: 41 additions & 0 deletions
41
packages/tswebextension/test/lib/mv2/background/services/document-blocking-service.test.ts
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,41 @@ | ||
import { DocumentBlockingService } from '@lib/mv2/background/services/document-blocking-service'; | ||
import { NetworkRule } from '@adguard/tsurlfilter'; | ||
import { ConfigurationMV2 } from '@lib/mv2'; | ||
import { getConfigurationMv2Fixture } from '../fixtures/configuration'; | ||
|
||
describe('DocumentBlockingService', () => { | ||
let documentBlockingService: DocumentBlockingService; | ||
|
||
beforeEach(() => { | ||
documentBlockingService = new DocumentBlockingService(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should not block URLs from trusted domains', () => { | ||
const trustedUrl = 'https://opulent-space-telegram-g4wx56pwp9q2vp5j.github.dev/blabla'; | ||
const trustedDomain = 'opulent-space-telegram-g4wx56pwp9q2vp5j.github.dev'; | ||
const mockNetworkRule = new NetworkRule('example.org', 0); | ||
|
||
const mockConfig: ConfigurationMV2 = { | ||
...getConfigurationMv2Fixture(), | ||
...{ | ||
trustedDomains: [trustedDomain], | ||
}, | ||
}; | ||
|
||
documentBlockingService.configure(mockConfig); | ||
|
||
const result = documentBlockingService.getDocumentBlockingResponse({ | ||
tabId: 1, | ||
eventId: 'someEvent', | ||
rule: mockNetworkRule, | ||
referrerUrl: 'someReferrer', | ||
requestUrl: trustedUrl, | ||
}); | ||
|
||
expect(result).toBeUndefined(); | ||
}); | ||
}); |