From 8c79b48721778469c15fe1e3c8bbc0bf2dc2f88e Mon Sep 17 00:00:00 2001 From: youssef Date: Sun, 15 Sep 2024 15:09:59 +0100 Subject: [PATCH] New Adapter: Missena - Updated --- adapters/missena/missena.go | 43 ++++--- adapters/missena/missena_test.go | 2 +- .../missena/missenatest/exemplary/ipv6.json | 105 ++++++++++++++++ .../missenatest/exemplary/multiple-imps.json | 115 ++++++++++++++++++ .../missenatest/exemplary/simple-banner.json | 2 +- .../missenatest/supplemental/status-204.json | 2 +- .../missenatest/supplemental/status-400.json | 2 +- .../supplemental/status-not-200.json | 2 +- adapters/missena/params_test.go | 7 +- static/bidder-info/missena.yaml | 2 +- static/bidder-params/missena.json | 3 +- 11 files changed, 257 insertions(+), 28 deletions(-) create mode 100644 adapters/missena/missenatest/exemplary/ipv6.json create mode 100644 adapters/missena/missenatest/exemplary/multiple-imps.json diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 73b2be27b9c..cc68f7ec68d 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -73,7 +73,7 @@ func (a *adapter) makeParameter(missenaParams MissenaInternalParams, request *op return &missenaRequest } -func (a *adapter) makeRequest(missenaParams MissenaInternalParams, reqInfo *adapters.ExtraRequestInfo, existingRequests []*adapters.RequestData, request *openrtb2.BidRequest) (*adapters.RequestData, error) { +func (a *adapter) makeRequest(missenaParams MissenaInternalParams, reqInfo *adapters.ExtraRequestInfo, imp *openrtb2.Imp, request *openrtb2.BidRequest) (*adapters.RequestData, error) { url := a.endpoint + "?t=" + missenaParams.ApiKey parameter := a.makeParameter(missenaParams, request) @@ -106,22 +106,26 @@ func (a *adapter) makeRequest(missenaParams MissenaInternalParams, reqInfo *adap Uri: url, Headers: headers, Body: body, - ImpIDs: openrtb_ext.GetImpIDs(request.Imp), + ImpIDs: []string{imp.ID}, }, nil } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + // print the request var httpRequests []*adapters.RequestData - var tempErrors []error + var errors []error gdprApplies, consentString := readGDPR(request) - var missenaInternalParams MissenaInternalParams + missenaInternalParams := MissenaInternalParams{ + GDPR: gdprApplies, + GDPRConsent: consentString, + } for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { - tempErrors = append(tempErrors, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: "Error parsing bidderExt object", }) continue @@ -129,7 +133,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var missenaExt openrtb_ext.ExtImpMissena if err := json.Unmarshal(bidderExt.Bidder, &missenaExt); err != nil { - tempErrors = append(tempErrors, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: "Error parsing missenaExt parameters", }) continue @@ -138,25 +142,25 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte missenaInternalParams.ApiKey = missenaExt.ApiKey missenaInternalParams.Placement = missenaExt.Placement missenaInternalParams.TestMode = missenaExt.TestMode - } - var finalErrors []error - missenaInternalParams.GDPR = gdprApplies - missenaInternalParams.GDPRConsent = consentString + newHttpRequest, err := a.makeRequest(missenaInternalParams, requestInfo, &imp, request) + if err != nil { + errors = append(errors, err) + continue + } - newHttpRequest, err := a.makeRequest(missenaInternalParams, requestInfo, httpRequests, request) + httpRequests = append(httpRequests, newHttpRequest) - if len(tempErrors) > 0 { - return nil, tempErrors + break } - if err != nil { - finalErrors = append(finalErrors, err) - } else if newHttpRequest != nil { - httpRequests = append(httpRequests, newHttpRequest) + if len(httpRequests) == 0 && len(errors) == 0 { + errors = append(errors, &errortypes.BadInput{ + Message: "No valid impressions found", + }) } - return httpRequests, finalErrors + return httpRequests, errors } func readGDPR(request *openrtb2.BidRequest) (bool, string) { @@ -221,6 +225,5 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse.Bids = append(bidResponse.Bids, b) - var errors []error - return bidResponse, errors + return bidResponse, nil } diff --git a/adapters/missena/missena_test.go b/adapters/missena/missena_test.go index 25169f9f282..2b13bf085db 100644 --- a/adapters/missena/missena_test.go +++ b/adapters/missena/missena_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderMissena, config.Adapter{ - Endpoint: "https://bid.missena.io"}, + Endpoint: "http://example.com/"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) if buildErr != nil { diff --git a/adapters/missena/missenatest/exemplary/ipv6.json b/adapters/missena/missenatest/exemplary/ipv6.json new file mode 100644 index 00000000000..ea240f82e09 --- /dev/null +++ b/adapters/missena/missenatest/exemplary/ipv6.json @@ -0,0 +1,105 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": [ + "EUR" + ], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "device": { + "ipv6": "2001:0000:130F:0000:0000:09C0:876A:130B", + "ua": "test-user-agent" + }, + "site": { + "page": "https://example.com/page", + "domain": "example.com" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement", + "test": "1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?t=test-api-key", + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ], + "User-Agent": [ + "test-user-agent" + ], + "X-Forwarded-For": [ + "2001:0000:130F:0000:0000:09C0:876A:130B" + ], + "Referer": [ + "https://example.com/page" + ] + }, + "body": { + "request_id": "test-request-id", + "timeout": 2000, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "consent_required": true, + "placement": "test-placement", + "test": "1" + }, + "impIDs":["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "ad": "
test ad
", + "cpm": 1.5, + "currency": "EUR", + "requestId": "test-request-id" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ + { + "bid": { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1.5, + "adm": "
test ad
", + "crid": "test-request-id" + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/missena/missenatest/exemplary/multiple-imps.json b/adapters/missena/missenatest/exemplary/multiple-imps.json new file mode 100644 index 00000000000..6b1db679542 --- /dev/null +++ b/adapters/missena/missenatest/exemplary/multiple-imps.json @@ -0,0 +1,115 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": [ + "EUR" + ], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "device": { + "ip": "123.123.123.123", + "ua": "test-user-agent" + }, + "site": { + "page": "https://example.com/page", + "domain": "example.com" + }, + "imp": [ + { + "id": "test-imp-id-1", + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement-1", + "test": "1" + } + } + }, + { + "id": "test-imp-id-2", + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": "abc" + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?t=test-api-key", + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ], + "User-Agent": [ + "test-user-agent" + ], + "X-Forwarded-For": [ + "123.123.123.123" + ], + "Referer": [ + "https://example.com/page" + ] + }, + "body": { + "request_id": "test-request-id", + "timeout": 2000, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "consent_required": true, + "placement": "test-placement-1", + "test": "1" + }, + "impIDs":["test-imp-id-1"] + }, + "mockResponse": { + "status": 200, + "body": { + "ad": "
test ad
", + "cpm": 1.5, + "currency": "EUR", + "requestId": "test-request-id" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ + { + "bid": { + "id": "test-request-id", + "impid": "test-imp-id-1", + "price": 1.5, + "adm": "
test ad
", + "crid": "test-request-id" + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/missena/missenatest/exemplary/simple-banner.json b/adapters/missena/missenatest/exemplary/simple-banner.json index 98fc041e04b..74ff3abfd57 100644 --- a/adapters/missena/missenatest/exemplary/simple-banner.json +++ b/adapters/missena/missenatest/exemplary/simple-banner.json @@ -44,7 +44,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://bid.missena.io?t=test-api-key", + "uri": "http://example.com/?t=test-api-key", "headers": { "Content-Type": [ "application/json;charset=utf-8" diff --git a/adapters/missena/missenatest/supplemental/status-204.json b/adapters/missena/missenatest/supplemental/status-204.json index eb266d97889..59070ab4ecb 100644 --- a/adapters/missena/missenatest/supplemental/status-204.json +++ b/adapters/missena/missenatest/supplemental/status-204.json @@ -44,7 +44,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://bid.missena.io?t=test-api-key", + "uri": "http://example.com/?t=test-api-key", "headers": { "Content-Type": [ "application/json;charset=utf-8" diff --git a/adapters/missena/missenatest/supplemental/status-400.json b/adapters/missena/missenatest/supplemental/status-400.json index 81f22bca933..23a153208e3 100644 --- a/adapters/missena/missenatest/supplemental/status-400.json +++ b/adapters/missena/missenatest/supplemental/status-400.json @@ -44,7 +44,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://bid.missena.io?t=test-api-key", + "uri": "http://example.com/?t=test-api-key", "headers": { "Content-Type": [ "application/json;charset=utf-8" diff --git a/adapters/missena/missenatest/supplemental/status-not-200.json b/adapters/missena/missenatest/supplemental/status-not-200.json index 6a90a824076..8c913791fc3 100644 --- a/adapters/missena/missenatest/supplemental/status-not-200.json +++ b/adapters/missena/missenatest/supplemental/status-not-200.json @@ -44,7 +44,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://bid.missena.io?t=test-api-key", + "uri": "http://example.com/?t=test-api-key", "headers": { "Content-Type": [ "application/json;charset=utf-8" diff --git a/adapters/missena/params_test.go b/adapters/missena/params_test.go index 8b27e7a0076..e76b80b694f 100644 --- a/adapters/missena/params_test.go +++ b/adapters/missena/params_test.go @@ -34,12 +34,17 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"apiKey": ""}`, `{"apiKey": "PA-123456"}`, `{"apiKey": "PA-123456", "placement": "sticky"}`, + `{"apiKey": "PA-123456", "test": "native"}`, } var invalidParams = []string{ + `{"apiKey": ""}`, `{"apiKey": 42}`, `{"placement": 111}`, + `{"placement": "sticky"}`, + `{"apiKey": "PA-123456", "placement": 111}`, + `{"test": "native"}`, + `{"apiKey": "PA-123456", "test": 111}`, } diff --git a/static/bidder-info/missena.yaml b/static/bidder-info/missena.yaml index ad67d4f291f..415548a31fb 100644 --- a/static/bidder-info/missena.yaml +++ b/static/bidder-info/missena.yaml @@ -1,6 +1,6 @@ endpoint: https://bid.missena.io/ maintainer: - email: yboussafa@missena.com + email: prebid@missena.com gvlVendorID: 687 modifyingVastXmlAllowed: true capabilities: diff --git a/static/bidder-params/missena.json b/static/bidder-params/missena.json index e3f3b0823b9..c9e20e5a828 100644 --- a/static/bidder-params/missena.json +++ b/static/bidder-params/missena.json @@ -6,7 +6,8 @@ "properties": { "apiKey": { "type": "string", - "description": "API Key" + "description": "API Key", + "minLength": 1 }, "placement": { "type": "string",