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

Huaweiadsadapter gdpr #2345

Merged
merged 31 commits into from
Oct 5, 2022
Merged

Huaweiadsadapter gdpr #2345

merged 31 commits into from
Oct 5, 2022

Conversation

clho40
Copy link
Contributor

@clho40 clho40 commented Aug 8, 2022

  • Get the country value from the MCC code
  • Get the GAID from the Openrtb.device.ifa field by default

@bsardo bsardo self-requested a review August 8, 2022 18:06
@bsardo bsardo self-assigned this Aug 8, 2022
@bsardo bsardo requested a review from mansinahar August 8, 2022 18:06
return errors.New("Unmarshal: openRTBRequest.User.Ext -> extUserDataHuaweiAds failed")
}
var deviceId = extUserDataHuaweiAds.Data
if len(deviceId.Imei) == 0 && len(deviceId.Gaid) == 0 && len(device.Gaid) == 0 && len(deviceId.Oaid) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to check for the length of device.Gaid or was that added by mistake? Looks like you already have a conditional before that to check length of deviceId.Gaid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for the confusion. at line#665 we tried to assign device.ifa to device.gaid field. Therefore we are checking for the existence of this value at this point, if all of them are empty we'll return an error

@clho40
Copy link
Contributor Author

clho40 commented Aug 15, 2022

@GenarC

@bsardo
Copy link
Collaborator

bsardo commented Aug 22, 2022

Hello @clho-huawei, @clho40,
Could you please merge with master to resolve the conflicts?

@clho40
Copy link
Contributor Author

clho40 commented Aug 22, 2022

@bsardo Hello. Thanks for reminding. We are doing some final checks and will merge them soon :)

@bsardo
Copy link
Collaborator

bsardo commented Aug 29, 2022

Hello @clho40, a couple of tests are failing due to formatting issues. Can you please run go fmt to resolve these? Thanks!

if userObjExist {
var extUserDataHuaweiAds openrtb_ext.ExtUserDataHuaweiAds
if err := json.Unmarshal(openRTBRequest.User.Ext, &extUserDataHuaweiAds); err != nil {
return errors.New("get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal openRTBRequest.User.Ext -> extUserDataHuaweiAds.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend appending the actual unmarshal error to your error message so that it can be helpful in debugging. Something like:

return fmt.Errorf("get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal error: %v", err)

@bsardo bsardo requested review from VeronikaSolovei9 and removed request for bsardo September 21, 2022 17:20
@bsardo bsardo assigned VeronikaSolovei9 and unassigned bsardo Sep 21, 2022
@@ -459,10 +459,14 @@ func getReqJson(request *huaweiAdsRequest, openRTBRequest *openrtb2.BidRequest,
func getReqAdslot30(huaweiAdsImpExt *openrtb_ext.ExtImpHuaweiAds,
openRTBImp *openrtb2.Imp, openRTBRequest *openrtb2.BidRequest) (adslot30, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

openRTBRequest *openrtb2.BidRequest parameter became unused, can you please delete it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Parameter is deleted.

@@ -459,10 +459,14 @@ func getReqJson(request *huaweiAdsRequest, openRTBRequest *openrtb2.BidRequest,
func getReqAdslot30(huaweiAdsImpExt *openrtb_ext.ExtImpHuaweiAds,
openRTBImp *openrtb2.Imp, openRTBRequest *openrtb2.BidRequest) (adslot30, error) {
adtype := convertAdtypeStringToInteger(strings.ToLower(huaweiAdsImpExt.Adtype))
testStatus := 0
if huaweiAdsImpExt != nil && huaweiAdsImpExt.IsTestAuthorization == "true" {
Copy link
Contributor

Choose a reason for hiding this comment

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

if huaweiAdsImpExt != nil check is not needed here, it's executed before the getReqAdslot30 function call, L281

Copy link
Contributor

Choose a reason for hiding this comment

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

Null check is removed

}
}
}

// getDeviceID include oaid gaid imei. In prebid mobile, use TargetingParams.addUserData("imei", "imei-test");
// When ifa: gaid exists, other device id can be passed by TargetingParams.addUserData("oaid", "oaid-test");
// When getGaidFromDeviceIFA success, getDeviceIDFromUserExt failed, no error will be reported.
Copy link
Contributor

Choose a reason for hiding this comment

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

Function getGaidFromDeviceIFA doesn't exist anymore, please modify comment accordingly

Copy link
Contributor

Choose a reason for hiding this comment

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

Because "getGaidFromDeviceIFA" function is removed, the comment is removed also.

return errors.New("get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal openRTBRequest.User.Ext -> extUserDataHuaweiAds. Error: " + err.Error())
}
var deviceId = extUserDataHuaweiAds.Data
if len(deviceId.Imei) == 0 && len(deviceId.Gaid) == 0 && len(device.Gaid) == 0 && len(deviceId.Oaid) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Small optional optimization: to avoid double evaluation of len(deviceId.Imei) == 0 and others, this if condition can be removed. Instead do this:

                 isValidDeviceId := false
                 if len(deviceId.Oaid) > 0 {
			device.Oaid = deviceId.Oaid[0]
                         isValidDeviceId = true
		}
		if len(deviceId.Gaid) > 0 {
			device.Gaid = deviceId.Gaid[0]
                         isValidDeviceId = true
		}
		if len(deviceId.Imei) > 0 {
                         if len(deviceId.Imei) > 0{
                                  device.Imei = deviceId.Imei[0]
                                  isValidDeviceId = true
                         }
		}
                 if !isValidDeviceId{
                           return errors.New("getDeviceID: Imei ,Oaid, Gaid are all empty.")
                 }

Copy link
Contributor

Choose a reason for hiding this comment

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

Recommendation is applied

Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 left a comment

Choose a reason for hiding this comment

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

Thank you for the updates, LGTM

@bsardo bsardo requested review from AlexBVolcy and mansinahar and removed request for mansinahar September 27, 2022 17:17
@bsardo bsardo assigned AlexBVolcy and unassigned mansinahar Sep 27, 2022
Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

Just some comments related to code coverage

intVar, err := strconv.Atoi(countryMCC)

if err != nil {
return defaultCountryName
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to trigger/cover this line of code

Copy link
Contributor

Choose a reason for hiding this comment

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

banner4_mccmnc.json file is used to cover line 783.

Copy link
Contributor

@AlexBVolcy AlexBVolcy Oct 4, 2022

Choose a reason for hiding this comment

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

@GenarC I still see this line uncovered when I run the tests in the huaweiads package

@VeronikaSolovei9
Copy link
Contributor

VeronikaSolovei9 commented Oct 4, 2022

Thank you for adding test. However it doesn't add coverage for the places Alex mentioned.

  1. To add coverage for L822 you need to modify newly added test:
    mockBidRequest.user.ext.data add "imei": ["test"] and check it in httpcalls.expectedRequest.body.device.imei: "test"

  2. To add coverage for L786 you need to add a test where mockBidRequest.device.mccmnc is a string constant that cannot be converted to number, something like "test". Also remove mockBidRequest.device.geo and mockBidRequest.uase.geo from request.

  3. To add coverage for L791 please follow directions in point 2 and set mockBidRequest.device.mccmnc to value that doesn't exist in MccList, something like "800-1"

This should add needed coverage

Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 left a comment

Choose a reason for hiding this comment

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

Thank you for adding tests, LGTM

@GenarC
Copy link
Contributor

GenarC commented Oct 5, 2022

Thanks for the help and the feedbacks

@bsardo bsardo merged commit 91336f6 into prebid:master Oct 5, 2022
gwi-mmuths added a commit to gwinteractive/prebid-server that referenced this pull request Oct 10, 2022
* origin/master: (316 commits)
  Fix alt bidder code test broken by imp wrapper commit (prebid#2405)
  ImpWrapper (prebid#2375)
  Update sspBC adapter to v5.7 (prebid#2394)
  Change errors to warnings (prebid#2385)
  TheMediaGrid: support native mediaType (prebid#2377)
  Huaweiadsadapter gdpr (prebid#2345)
  Add alternatebiddercodes in Prebid request ext (prebid#2339)
  Changed FS bidder names to mixed case (prebid#2390)
  Load bidders names from file system in lowercase (prebid#2388)
  consumable adapter: add schain and coppa support (prebid#2361)
  Adapter aliases: moved adapter related configs to bidder.yaml files (prebid#2353)
  pubmatic adapter: add param prebiddealpriority (prebid#2281)
  Yieldlab Adapter: Add support for ad unit sizes (prebid#2364)
  GDPR: add enforce_algo config flag and convert enforce_purpose to bool (prebid#2330)
  Resolves CVE-2022-27664 (prebid#2376)
  AMP Endpoint: support parameters consentType and gdprApplies (prebid#2338)
  Dianomi - added usync for redirect (prebid#2368)
  Create issue_prioritization.yml (prebid#2372)
  Update yaml files for gzip supported bidders (prebid#2365)
  Adnuntius Adapter: Set no cookies as a parameter (prebid#2352)
  ...
shunj-nb pushed a commit to ParticleMedia/prebid-server that referenced this pull request Nov 8, 2022
Co-authored-by: Ho Chia Leung <[email protected]>
Co-authored-by: Cem Genar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants