Skip to content
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

Aliasbidder fix #1652

Merged
merged 7 commits into from
Oct 6, 2017
Merged

Aliasbidder fix #1652

merged 7 commits into from
Oct 6, 2017

Conversation

jaiminpanchal27
Copy link
Collaborator

Type of change

  • Bugfix

Description of change

Fix for #1643
Also, aliased adapter could only support banner mediaType. Fixed that too.

newAdapter.setBidderCode(alias);
} else {
let spec = Object.assign({}, bidAdaptor, { code: alias });
newAdapter = newBidder(spec);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little buggy.

The bidderFactory accepts a spec, but only returns an object like:

{
  callBids: function() { ... }
}

So in this code, you're using objects of the shape:

newAdapter = newBidder({
  code: alias,
  callBids: function() { ... }
});

...but newBIdder needs a spec. The typedef doesn't have callBids, but does require several other things which you're not giving here (interpretResponse, buildRequests, etc).

So... if callBids gets called on an aliased bidder, there'll be all sorts of errors about missing functions.

@@ -138,6 +138,9 @@ export function registerBidder(spec) {
*/
export function newBidder(spec) {
return Object.assign(new Adapter(spec.code), {
getSpec: function() {
Copy link
Contributor

@dbemiller dbemiller Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth doing an Object.freeze on the spec here.

Otherwise someone could call getSpec() and then mutate that object, producing some absolutely horrible bugs. IMO, the burden lies on the file implementer to make sure there's no way to "misuse" the functions they make public.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

const thisSpec = Object.assign(spec, { supportedMediaTypes: ['video'] });
registerBidder(thisSpec);
const alias = 'aliasBidder';
$$PREBID_GLOBAL$$.aliasBidder(CODE, alias);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid $$PREBID_GLOBAL$$ in tests (see #1508).

Prebid-specifics aside... strong unit tests cover the smallest amount of code possible. All your changes are in adapterManager... so it's much better if your tests import the adapterManager and call the functions directly. The $$PREBID_GLOBAL$$.aliasBidder function is at a higher level, and would be better tested by stubbing the adapterManager with sinon and making sure the methods get called with the right args.

On a less important note... you could probably write these in test/spec/unit/adapterManager_spec.js. This file is much larger than it should be already.

@dbemiller dbemiller self-assigned this Oct 4, 2017
@@ -3,6 +3,9 @@ import AdapterManager from 'src/adaptermanager';
import { getAdUnits } from 'test/fixtures/fixtures';
import CONSTANTS from 'src/constants.json';
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';

require('modules/appnexusAstBidAdapter');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental import?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not accidental, i took a shortcut to test old way of aliasing adapter. Since we will be only keeping this code for a short time.

But anyway, updated test case to make it as it should be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok... no worries either way.

@dbemiller dbemiller assigned mkendall07 and unassigned dbemiller Oct 6, 2017
@dbemiller dbemiller added the LGTM label Oct 6, 2017
Copy link
Member

@mkendall07 mkendall07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mkendall07 mkendall07 merged commit 6186a2c into master Oct 6, 2017
@matthewlane matthewlane deleted the aliasbidder-fix branch October 6, 2017 23:54
vzhukovsky added a commit to aol/Prebid.js that referenced this pull request Oct 25, 2017
….30.0 to aolgithub-master

* commit '5a8d2bf93ee15071a78e24ac976103cacf3c6021': (35 commits)
  Added changelog entry.
  Prebid 0.30.1 Release
  Remove undefined variable usage (prebid#1662)
  fixes bug for IE when invalid value passed to parse (prebid#1657)
  Aliasbidder fix (prebid#1652)
  prebidAdapter secure support (prebid#1655)
  Increment pre version
  Prebid 0.30.0 Release
  Add native param support to mediaTypes (prebid#1625)
  PulsePoint Lite adpater changes (prebid#1630)
  Appnexus ast unittest updates (prebid#1654)
  Support aspect ratio specification for native images (prebid#1634)
  Revert changes for switch between client side and server side. (prebid#1653)
  rubicon converted to bidderFactory (prebid#1624)
  Add JSDoc for `pbjs.getAllWinningBids` (prebid#1566)
  Add ignore-loader to handle .md files (prebid#1646)
  fixed PBS cookie syncs (prebid#1637)
  Add placementId request param to Yieldmo bid adapter (prebid#1632)
  Adxcg analytics adapter (prebid#1599)
  Add publisher sub-id support to the Criteo adapter (prebid#1629)
  ...
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* aliasBidder did not work for bidderFactory

* added function to get adapter spec

* Freezing spec and moved unit tests

* Updated test case to not import adapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants