From c29a8842683eb35677e0adc6e13cef072fb506b6 Mon Sep 17 00:00:00 2001
From: Bill Newman <huddled.masses1650@gmail.com>
Date: Mon, 2 Dec 2019 20:04:03 +0200
Subject: [PATCH] Colossus adapter changes for Prebid 3.0 (#4476)

* add video&native traffic colossus ssp

* Native obj validation

* Native obj validation #2

* Added size field in requests

* fixed test

* fix merge conflicts

* move to 3.0

* move to 3.0

* fix IE11 new URL issue

* fix IE11 new URL issue

* fix IE11 new URL issue

* https for 3.0

* add https test
---
 modules/colossussspBidAdapter.js              | 21 +++++++++++--------
 modules/colossussspBidAdapter.md              |  6 +++++-
 .../modules/colossussspBidAdapter_spec.js     | 10 ++++++---
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js
index 2ad320ede38..9f02f5057c1 100644
--- a/modules/colossussspBidAdapter.js
+++ b/modules/colossussspBidAdapter.js
@@ -3,8 +3,8 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes';
 import * as utils from '../src/utils';
 
 const BIDDER_CODE = 'colossusssp';
-const URL = '//colossusssp.com/?c=o&m=multi';
-const URL_SYNC = '//colossusssp.com/?c=o&m=cookie';
+const G_URL = 'https://colossusssp.com/?c=o&m=multi';
+const G_URL_SYNC = 'https://colossusssp.com/?c=o&m=cookie';
 
 function isBidResponseValid(bid) {
   if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) {
@@ -42,15 +42,16 @@ export const spec = {
    * @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server.
    * @return ServerRequest Info describing the request to the server.
    */
-  buildRequests: (validBidRequests) => {
+  buildRequests: (validBidRequests, bidderRequest) => {
     let winTop = window;
+    let location;
     try {
-      window.top.location.toString();
+      location = new URL(bidderRequest.refererInfo.referer)
       winTop = window.top;
     } catch (e) {
+      location = winTop.location;
       utils.logMessage(e);
     };
-    let location = utils.getTopWindowLocation();
     let placements = [];
     let request = {
       'deviceWidth': winTop.screen.width,
@@ -61,19 +62,21 @@ export const spec = {
       'page': location.pathname,
       'placements': placements
     };
+
     for (let i = 0; i < validBidRequests.length; i++) {
       let bid = validBidRequests[i];
+      let traff = bid.params.traffic || BANNER
       let placement = {
         placementId: bid.params.placement_id,
         bidId: bid.bidId,
-        sizes: bid.sizes,
-        traffic: bid.params.traffic || BANNER
+        sizes: bid.mediaTypes[traff].sizes,
+        traffic: traff
       };
       placements.push(placement);
     }
     return {
       method: 'POST',
-      url: URL,
+      url: G_URL,
       data: request
     };
   },
@@ -103,7 +106,7 @@ export const spec = {
   getUserSyncs: () => {
     return [{
       type: 'image',
-      url: URL_SYNC
+      url: G_URL_SYNC
     }];
   }
 };
diff --git a/modules/colossussspBidAdapter.md b/modules/colossussspBidAdapter.md
index 4760002f0db..d95080546c2 100644
--- a/modules/colossussspBidAdapter.md
+++ b/modules/colossussspBidAdapter.md
@@ -14,7 +14,11 @@ Module that connects to Colossus SSP demand sources
 ```
     var adUnits = [{
                 code: 'placementid_0',
-                sizes: [[300, 250]],
+                mediaTypes: {
+                    banner: {
+                        sizes: [[300, 250], [300,600]]
+                    }
+                },
                 bids: [{
                         bidder: 'colossusssp',
                         params: {
diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js
index 62b4158676e..f5042220610 100644
--- a/test/spec/modules/colossussspBidAdapter_spec.js
+++ b/test/spec/modules/colossussspBidAdapter_spec.js
@@ -11,7 +11,11 @@ describe('ColossussspAdapter', function () {
     },
     placementCode: 'placementid_0',
     auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
-    sizes: [[300, 250]],
+    mediaTypes: {
+      banner: {
+        sizes: [[300, 250]]
+      }
+    },
     transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62'
   };
 
@@ -37,7 +41,7 @@ describe('ColossussspAdapter', function () {
       expect(serverRequest.method).to.equal('POST');
     });
     it('Returns valid URL', function () {
-      expect(serverRequest.url).to.equal('//colossusssp.com/?c=o&m=multi');
+      expect(serverRequest.url).to.equal('https://colossusssp.com/?c=o&m=multi');
     });
     it('Returns valid data if array of bids is valid', function () {
       let data = serverRequest.data;
@@ -112,7 +116,7 @@ describe('ColossussspAdapter', function () {
       expect(userSync[0].type).to.exist;
       expect(userSync[0].url).to.exist;
       expect(userSync[0].type).to.be.equal('image');
-      expect(userSync[0].url).to.be.equal('//colossusssp.com/?c=o&m=cookie');
+      expect(userSync[0].url).to.be.equal('https://colossusssp.com/?c=o&m=cookie');
     });
   });
 });