|
8 | 8 | "gopkg.in/yaml.v3"
|
9 | 9 |
|
10 | 10 | "github.com/prebid/prebid-server/v2/openrtb_ext"
|
| 11 | + "github.com/prebid/prebid-server/v2/util/ptrutil" |
11 | 12 | "github.com/stretchr/testify/assert"
|
12 | 13 | "github.com/stretchr/testify/require"
|
13 | 14 | )
|
@@ -401,6 +402,15 @@ func TestProcessAliasBidderInfo(t *testing.T) {
|
401 | 402 | Key: "bidderA",
|
402 | 403 | }
|
403 | 404 |
|
| 405 | + parentWithSyncerSupports := parentWithoutSyncerKey |
| 406 | + parentWithSyncerSupports.Syncer = &Syncer{ |
| 407 | + Supports: []string{"iframe"}, |
| 408 | + } |
| 409 | + |
| 410 | + aliasWithoutSyncer := parentWithoutSyncerKey |
| 411 | + aliasWithoutSyncer.AliasOf = "bidderA" |
| 412 | + aliasWithoutSyncer.Syncer = nil |
| 413 | + |
404 | 414 | testCases := []struct {
|
405 | 415 | description string
|
406 | 416 | aliasInfos map[string]aliasNillableFields
|
@@ -428,6 +438,26 @@ func TestProcessAliasBidderInfo(t *testing.T) {
|
428 | 438 | expectedErr: nil,
|
429 | 439 | expectedBidderInfos: BidderInfos{"bidderA": parentWithSyncerKey, "bidderB": bidderB},
|
430 | 440 | },
|
| 441 | + { |
| 442 | + description: "inherit all parent info in alias bidder, except for syncer is parent only defines supports", |
| 443 | + aliasInfos: map[string]aliasNillableFields{ |
| 444 | + "bidderB": { |
| 445 | + Disabled: nil, |
| 446 | + ModifyingVastXmlAllowed: nil, |
| 447 | + Experiment: nil, |
| 448 | + XAPI: nil, |
| 449 | + }, |
| 450 | + }, |
| 451 | + bidderInfos: BidderInfos{ |
| 452 | + "bidderA": parentWithSyncerSupports, |
| 453 | + "bidderB": BidderInfo{ |
| 454 | + AliasOf: "bidderA", |
| 455 | + // all other fields should be inherited from parent bidder, except for syncer |
| 456 | + }, |
| 457 | + }, |
| 458 | + expectedErr: nil, |
| 459 | + expectedBidderInfos: BidderInfos{"bidderA": parentWithSyncerSupports, "bidderB": aliasWithoutSyncer}, |
| 460 | + }, |
431 | 461 | {
|
432 | 462 | description: "inherit all parent info in alias bidder, use parent name as syncer alias key",
|
433 | 463 | aliasInfos: map[string]aliasNillableFields{
|
@@ -1522,6 +1552,77 @@ func TestSyncerEndpointOverride(t *testing.T) {
|
1522 | 1552 | }
|
1523 | 1553 | }
|
1524 | 1554 |
|
| 1555 | +func TestSyncerDefined(t *testing.T) { |
| 1556 | + testCases := []struct { |
| 1557 | + name string |
| 1558 | + givenSyncer *Syncer |
| 1559 | + expected bool |
| 1560 | + }{ |
| 1561 | + { |
| 1562 | + name: "nil", |
| 1563 | + givenSyncer: nil, |
| 1564 | + expected: false, |
| 1565 | + }, |
| 1566 | + { |
| 1567 | + name: "empty", |
| 1568 | + givenSyncer: &Syncer{}, |
| 1569 | + expected: false, |
| 1570 | + }, |
| 1571 | + { |
| 1572 | + name: "key-only", |
| 1573 | + givenSyncer: &Syncer{Key: "anyKey"}, |
| 1574 | + expected: true, |
| 1575 | + }, |
| 1576 | + { |
| 1577 | + name: "iframe-only", |
| 1578 | + givenSyncer: &Syncer{IFrame: &SyncerEndpoint{}}, |
| 1579 | + expected: true, |
| 1580 | + }, |
| 1581 | + { |
| 1582 | + name: "redirect-only", |
| 1583 | + givenSyncer: &Syncer{Redirect: &SyncerEndpoint{}}, |
| 1584 | + expected: true, |
| 1585 | + }, |
| 1586 | + { |
| 1587 | + name: "externalurl-only", |
| 1588 | + givenSyncer: &Syncer{ExternalURL: "anyURL"}, |
| 1589 | + expected: true, |
| 1590 | + }, |
| 1591 | + { |
| 1592 | + name: "supportscors-only", |
| 1593 | + givenSyncer: &Syncer{SupportCORS: ptrutil.ToPtr(false)}, |
| 1594 | + expected: true, |
| 1595 | + }, |
| 1596 | + { |
| 1597 | + name: "formatoverride-only", |
| 1598 | + givenSyncer: &Syncer{FormatOverride: "anyFormat"}, |
| 1599 | + expected: true, |
| 1600 | + }, |
| 1601 | + { |
| 1602 | + name: "skipwhen-only", |
| 1603 | + givenSyncer: &Syncer{SkipWhen: &SkipWhen{}}, |
| 1604 | + expected: true, |
| 1605 | + }, |
| 1606 | + { |
| 1607 | + name: "supports-only", |
| 1608 | + givenSyncer: &Syncer{Supports: []string{"anySupports"}}, |
| 1609 | + expected: false, |
| 1610 | + }, |
| 1611 | + { |
| 1612 | + name: "supports-with-other", |
| 1613 | + givenSyncer: &Syncer{Key: "anyKey", Supports: []string{"anySupports"}}, |
| 1614 | + expected: true, |
| 1615 | + }, |
| 1616 | + } |
| 1617 | + |
| 1618 | + for _, test := range testCases { |
| 1619 | + t.Run(test.name, func(t *testing.T) { |
| 1620 | + result := test.givenSyncer.Defined() |
| 1621 | + assert.Equal(t, test.expected, result) |
| 1622 | + }) |
| 1623 | + } |
| 1624 | +} |
| 1625 | + |
1525 | 1626 | func TestApplyBidderInfoConfigSyncerOverrides(t *testing.T) {
|
1526 | 1627 | var (
|
1527 | 1628 | givenFileSystem = BidderInfos{"a": {Syncer: &Syncer{Key: "original"}}}
|
|
0 commit comments