Repository: prebid/prebid-server
Pull request #2684 (2023-04-07 14:33:40)

adyoulike: update endpoint
Update adyoulike endpoint


Patch:
diff --git a/adapters/appnexus/appnexus.go b/adapters/appnexus/appnexus.go
index 785f718c..5c283f18 100644
--- a/adapters/appnexus/appnexus.go
+++ b/adapters/appnexus/appnexus.go
@@ -4,7 +4,6 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
-	"math/rand"
 	"net/http"
 	"strconv"
 	"strings"
@@ -14,6 +13,7 @@ import (
 	"github.com/prebid/openrtb/v17/openrtb2"
 	"github.com/prebid/prebid-server/config"
 	"github.com/prebid/prebid-server/util/httputil"
+	"github.com/prebid/prebid-server/util/randomutil"
 
 	"github.com/prebid/prebid-server/adapters"
 	"github.com/prebid/prebid-server/errortypes"
@@ -24,9 +24,10 @@ import (
 const defaultPlatformID int = 5
 
 type adapter struct {
-	URI            string
-	iabCategoryMap map[string]string
-	hbSource       int
+	URI             string
+	iabCategoryMap  map[string]string
+	hbSource        int
+	randomGenerator randomutil.RandomGenerator
 }
 
 var maxImpsPerReq = 10
@@ -39,7 +40,8 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co
 			"1": "IAB20-3",
 			"9": "IAB5-3",
 		},
-		hbSource: resolvePlatformID(config.PlatformID),
+		hbSource:        resolvePlatformID(config.PlatformID),
+		randomGenerator: randomutil.RandomNumberGenerator{},
 	}
 	return bidder, nil
 }
@@ -151,7 +153,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E
 	// If impressions number per pod is more than maxImpsPerReq - divide those imps to several requests but keep pod id the same
 	// If  adpodId feature disabled and impressions number per pod is more than maxImpsPerReq  - divide those imps to several requests but do not include ad pod id
 	if isVIDEO == 1 && *shouldGenerateAdPodId {
-		requests, errors := buildAdPodRequests(imps, request, reqExt, requestURI)
+		requests, errors := a.buildAdPodRequests(imps, request, reqExt, requestURI)
 		return requests, append(errs, errors...)
 	}
 
@@ -426,12 +428,12 @@ func buildDisplayManageVer(req *openrtb2.BidRequest) string {
 	return fmt.Sprintf("%s-%s", source, version)
 }
 
-func buildAdPodRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExtension appnexusReqExt, uri string) ([]*adapters.RequestData, []error) {
+func (a *adapter) buildAdPodRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExtension appnexusReqExt, uri string) ([]*adapters.RequestData, []error) {
 	var errs []error
 	podImps := groupByPods(imps)
 	requests := make([]*adapters.RequestData, 0, len(podImps))
 	for _, podImps := range podImps {
-		requestExtension.Appnexus.AdPodId = fmt.Sprint(rand.Int63())
+		requestExtension.Appnexus.AdPodId = fmt.Sprint(a.randomGenerator.GenerateInt63())
 
 		reqs, errors := splitRequests(podImps, request, requestExtension, uri)
 		requests = append(requests, reqs...)
diff --git a/static/bidder-info/adyoulike.yaml b/static/bidder-info/adyoulike.yaml
index d1ddae74..3342b884 100644
--- a/static/bidder-info/adyoulike.yaml
+++ b/static/bidder-info/adyoulike.yaml
@@ -1,4 +1,4 @@
-endpoint: "https://broker.omnitagjs.com/broker/bid?partnerId=19340f4f097d16f41f34fc0274981ca4"
+endpoint: "https://hb-ss.omnitagjs.com/broker/bid?partnerId=19340f4f097d16f41f34fc0274981ca4"
 maintainer:
   email: "core@adyoulike.com"
 gvlVendorID: 259
diff --git a/util/randomutil/randomutil.go b/util/randomutil/randomutil.go
new file mode 100644
index 00000000..544eb1ab
--- /dev/null
+++ b/util/randomutil/randomutil.go
@@ -0,0 +1,15 @@
+package randomutil
+
+import (
+	"math/rand"
+)
+
+type RandomGenerator interface {
+	GenerateInt63() int64
+}
+
+type RandomNumberGenerator struct{}
+
+func (RandomNumberGenerator) GenerateInt63() int64 {
+	return rand.Int63()
+}


Test patch:
diff --git a/adapters/appnexus/appnexus_test.go b/adapters/appnexus/appnexus_test.go
index 000d07e9..6797f4bb 100644
--- a/adapters/appnexus/appnexus_test.go
+++ b/adapters/appnexus/appnexus_test.go
@@ -16,6 +16,9 @@ func TestJsonSamples(t *testing.T) {
 		t.Fatalf("Builder returned unexpected error %v", buildErr)
 	}
 
+	bidderAppNexus, _ := bidder.(*adapter)
+	bidderAppNexus.randomGenerator = FakeRandomNumberGenerator{Number: 10}
+
 	adapterstest.RunJSONBidderTest(t, "appnexustest", bidder)
 }
 
@@ -26,3 +29,12 @@ func TestMemberQueryParam(t *testing.T) {
 		t.Errorf("appendMemberId() failed on URI with query string. Expected %s, got %s", expected, uriWithMember)
 	}
 }
+
+// fakerandomNumberGenerator
+type FakeRandomNumberGenerator struct {
+	Number int64
+}
+
+func (f FakeRandomNumberGenerator) GenerateInt63() int64 {
+	return f.Number
+}
diff --git a/adapters/appnexus/appnexustest/video/video-same-adpodid-two-imps-same-pod.json b/adapters/appnexus/appnexustest/video/video-same-adpodid-two-imps-same-pod.json
index 5a453979..86fa14aa 100644
--- a/adapters/appnexus/appnexustest/video/video-same-adpodid-two-imps-same-pod.json
+++ b/adapters/appnexus/appnexustest/video/video-same-adpodid-two-imps-same-pod.json
@@ -47,7 +47,7 @@
 			"id": "test-request-id",
 			"ext": {
 				"appnexus": {
-				 "adpod_id": "5577006791947779410",
+				 "adpod_id": "10",
 				  "hb_source": 6
 				},
 				"prebid": {}