Skip to content

Commit

Permalink
fix(FEC-14248): Anonymous session based on if ks contain user - fix (#…
Browse files Browse the repository at this point in the history
…261)

### Description of the Changes

- Fix for always adding ks as a parameter for
'OVPProviderParser.getMediaEntry' and 'OVPProviderParser.getBumper'.

Related PR: 
[259](#259)
[916](kaltura/kaltura-player-js#916)

[FEC-14248](https://kaltura.atlassian.net/browse/FEC-14248)

[FEC-14248]:
https://kaltura.atlassian.net/browse/FEC-14248?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: Roee Dean <[email protected]>
  • Loading branch information
roeedean and Roee Dean authored Feb 11, 2025
1 parent ea59451 commit d258629
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/k-provider/ovp/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
messages: OVPProviderParser.getErrorMessages(response)
});
}
const mediaEntry = OVPProviderParser.getMediaEntry(this.isAnonymous ? '' : this.ks, this.partnerId, this.uiConfId, response);
const mediaEntry = OVPProviderParser.getMediaEntry(this.ks, this.partnerId, this.uiConfId, response);
Object.assign(mediaConfig.sources, this._getSourcesObject(mediaEntry));
this._verifyMediaStatus(mediaEntry);
this._verifyHasSources(mediaConfig.sources);
const bumper = OVPProviderParser.getBumper(response, this.isAnonymous ? '' : this.ks, this.partnerId);
const bumper = OVPProviderParser.getBumper(response, this.ks, this.partnerId);
if (bumper) {
Object.assign(mediaConfig.plugins, {bumper});
}
Expand Down
59 changes: 59 additions & 0 deletions test/src/k-provider/ovp/provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,65 @@ describe('OVPProvider.partnerId:0', function () {
});
});

describe('OVPProvider KS inclusion', function () {
let provider, sandbox;
const partnerId = 1082342;
const playerVersion = '1.2.3';
const ks = 'test_ks';

beforeEach(() => {
sandbox = sinon.createSandbox();
provider = new OVPProvider({ partnerId: partnerId, ks: ks }, playerVersion);

sandbox.stub(MultiRequestBuilder.prototype, 'execute').resolves(
Promise.resolve({
response: new Map([
['session', { response: ks }],
['mediaEntry', { response: {} }]
])
})
);

sandbox.stub(provider, '_parseDataFromResponse').callsFake(() => ({
session: { ks: ks, isAnonymous: provider._isAnonymous, partnerId: partnerId },
sources: {},
plugins: {}
}));

sandbox.stub(provider, 'getMediaConfig').callsFake(() => {
return Promise.resolve({
session: { ks: ks, isAnonymous: provider._isAnonymous, partnerId: partnerId },
sources: {},
plugins: {}
});
});
});

afterEach(() => {
sandbox.restore();
});

it('should include ks in getMediaConfig response when isAnonymous is true', function (done) {
provider._isAnonymous = true;
provider.getMediaConfig({ entryId: '1_rsrdfext', ks: ks }).then(
(mediaConfig) => {
sinon.assert.match(mediaConfig.session.ks, ks);
done();
}
).catch(done);
});

it('should include ks in getMediaConfig response when isAnonymous is false', function (done) {
provider._isAnonymous = false;
provider.getMediaConfig({ entryId: '1_rsrdfext', ks: ks }).then(
(mediaConfig) => {
sinon.assert.match(mediaConfig.session.ks, ks);
done();
}
).catch(done);
});
});

describe('getMediaConfig', function () {
let provider, sandbox;
const partnerId = 1068292;
Expand Down

0 comments on commit d258629

Please sign in to comment.