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

Unicorn: Revert limitation of JPY only ( add limitation of accountId ) #2277

Merged
merged 6 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions adapters/unicorn/unicorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
}
}

if len(request.Cur) == 0 {
request.Cur = []string{"JPY"}
} else if isOtherThanJPY(request.Cur) {
return nil, []error{&errortypes.BadInput{
Message: "Only JPY is supported",
}}
}

err := modifyImps(request)
if err != nil {
return nil, []error{err}
Expand Down Expand Up @@ -106,15 +98,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
return []*adapters.RequestData{requestData}, nil
}

func isOtherThanJPY(cur []string) bool {
for _, c := range cur {
if c != "JPY" {
return true
}
}
return false
}

func getHeaders(request *openrtb2.BidRequest) http.Header {
headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
Expand Down Expand Up @@ -191,8 +174,9 @@ func setSourceExt() json.RawMessage {
func setExt(request *openrtb2.BidRequest) (json.RawMessage, error) {
accountID, err := jsonparser.GetInt(request.Imp[0].Ext, "bidder", "accountId")
if err != nil {
accountID = 0
return nil, fmt.Errorf("accountId field is required")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add coverage for this line?

Copy link
Contributor Author

@faithnh faithnh Jun 21, 2022

Choose a reason for hiding this comment

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

This line was not able to pass, so investigated it.

I found bug that acccountId set zero in modifyImps when not have accountId.

So i fixed it, and added test case that not have accountId.

This line is passed now.

4b0121f

}

var decodedExt *unicornExt
err = json.Unmarshal(request.Ext, &decodedExt)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
"ver": "1.9.0"
},
"at": 1,
"cur": ["JPY"],
"device": {
"connectiontype": 1,
"ext": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
}
],
"cur": ["JPY"],
"cur": ["USD"],
"app": {
"publisher": {
"id": "test"
Expand Down Expand Up @@ -96,7 +96,7 @@
"ver": "1.9.0"
},
"at": 1,
"cur": ["JPY"],
"cur": ["USD"],
"device": {
"connectiontype": 1,
"ext": {
Expand Down
243 changes: 0 additions & 243 deletions adapters/unicorn/unicorntest/exemplary/not-have-cur.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@
}
},
"bidder": {
"accountId": 199578,
"accountId": "hogeohge",
"publisherId": 123456,
"mediaId": "test_media",
"placementId": "test_placement"
},
"context": {
"data": {
"firstPartyData1": ["firstPartyData1"],
"uuid": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]
}
}
}
}
],
"cur": ["USD"],
"cur": ["JPY"],
"app": {
"publisher": {
"id": "test"
Expand Down Expand Up @@ -70,21 +64,12 @@
},
"user": {
"gender": "O"
},
"ext": {
"prebid": {
"targeting": {},
"cache": {
"bids": {}
},
"storedrequest": {
"id": "test"
}
}
}
},
"expectedMakeRequestsErrors" : [{
"value": "Only JPY is supported",
"comparison": "literal"
}]
"expectedMakeRequestsErrors": [
{
"value": "Error while decoding imp[0].ext: json: cannot unmarshal string into Go struct field ExtImpUnicorn.bidder.accountId of type int",
"comparison": "literal"
}
]
}
Loading