-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add unit tests and integration test #448
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9701f56
add integration test for cached encryption key
ff06923
add unit tests
56143a8
adding segment-loader test
1189a3d
adding some comments per CR and a negative case for cacheEncryptionKe…
b57a4d0
negative test for cacheEncryptionKeys:false
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,7 +252,7 @@ QUnit.module('SegmentLoader: M2TS', function(hooks) { | |
'segment end time not shifted by mp4 start time'); | ||
}); | ||
|
||
QUnit.test('segmentKey will cache new encrypted keys', function(assert) { | ||
QUnit.test('segmentKey will cache new encrypted keys with cacheEncryptionKeys true', function(assert) { | ||
const newLoader = new SegmentLoader(LoaderCommonSettings.call(this, { | ||
loaderType: 'main', | ||
segmentMetadataTrack: this.segmentMetadataTrack, | ||
|
@@ -296,6 +296,40 @@ QUnit.module('SegmentLoader: M2TS', function(hooks) { | |
); | ||
}); | ||
|
||
QUnit.test('segmentKey will not cache encrypted keys with cacheEncryptionKeys false', function(assert) { | ||
const newLoader = new SegmentLoader(LoaderCommonSettings.call(this, { | ||
loaderType: 'main', | ||
segmentMetadataTrack: this.segmentMetadataTrack, | ||
cacheEncryptionKeys: false | ||
}), {}); | ||
|
||
newLoader.playlist(playlistWithDuration(10), { isEncrypted: true }); | ||
newLoader.mimeType(this.mimeType); | ||
newLoader.load(); | ||
this.clock.tick(1); | ||
|
||
assert.strictEqual( | ||
Object.keys(newLoader.keyCache_).length, | ||
0, | ||
'no keys have been cached' | ||
); | ||
|
||
newLoader.segmentKey( | ||
{ | ||
resolvedUri: 'key.php', | ||
bytes: new Uint32Array([1, 2, 3, 4]) | ||
}, | ||
// set = true | ||
true | ||
); | ||
|
||
assert.strictEqual( | ||
Object.keys(newLoader.keyCache_).length, | ||
0, | ||
'no keys have been cached since cacheEncryptionKeys is false' | ||
); | ||
}); | ||
|
||
QUnit.test('new segment requests will use cached keys', function(assert) { | ||
const done = assert.async(); | ||
const newLoader = new SegmentLoader(LoaderCommonSettings.call(this, { | ||
|
@@ -326,6 +360,8 @@ QUnit.module('SegmentLoader: M2TS', function(hooks) { | |
standardXHRResponse(this.requests.shift(), new Uint32Array([1, 5, 0, 1])); | ||
this.clock.tick(1); | ||
|
||
// As the Decrypter is in a web worker, the last function in SegmentLoader is | ||
// the easiest way to listen for the decrypted response | ||
const origHandleSegment = newLoader.handleSegment_.bind(newLoader); | ||
|
||
newLoader.handleSegment_ = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I must be missing something, but how/when does this function get called? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. answer, decrypt worker runs in webworker so its async |
||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol oops