github.com/prebid/prebid-server/v2@v2.18.0/gdpr/aggregated_config_test.go (about)

     1  package gdpr
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/prebid/go-gdpr/consentconstants"
     7  
     8  	"github.com/prebid/prebid-server/v2/config"
     9  	"github.com/prebid/prebid-server/v2/openrtb_ext"
    10  
    11  	"github.com/stretchr/testify/assert"
    12  )
    13  
    14  func MakeTCF2ConfigPurposeMaps(tcf2Config *tcf2Config) {
    15  	tcf2Config.AccountConfig.PurposeConfigs = map[consentconstants.Purpose]*config.AccountGDPRPurpose{
    16  		1:  &tcf2Config.AccountConfig.Purpose1,
    17  		2:  &tcf2Config.AccountConfig.Purpose2,
    18  		3:  &tcf2Config.AccountConfig.Purpose3,
    19  		4:  &tcf2Config.AccountConfig.Purpose4,
    20  		5:  &tcf2Config.AccountConfig.Purpose5,
    21  		6:  &tcf2Config.AccountConfig.Purpose6,
    22  		7:  &tcf2Config.AccountConfig.Purpose7,
    23  		8:  &tcf2Config.AccountConfig.Purpose8,
    24  		9:  &tcf2Config.AccountConfig.Purpose9,
    25  		10: &tcf2Config.AccountConfig.Purpose10,
    26  	}
    27  
    28  	tcf2Config.HostConfig.PurposeConfigs = map[consentconstants.Purpose]*config.TCF2Purpose{
    29  		1:  &tcf2Config.HostConfig.Purpose1,
    30  		2:  &tcf2Config.HostConfig.Purpose2,
    31  		3:  &tcf2Config.HostConfig.Purpose3,
    32  		4:  &tcf2Config.HostConfig.Purpose4,
    33  		5:  &tcf2Config.HostConfig.Purpose5,
    34  		6:  &tcf2Config.HostConfig.Purpose6,
    35  		7:  &tcf2Config.HostConfig.Purpose7,
    36  		8:  &tcf2Config.HostConfig.Purpose8,
    37  		9:  &tcf2Config.HostConfig.Purpose9,
    38  		10: &tcf2Config.HostConfig.Purpose10,
    39  	}
    40  }
    41  
    42  func TestIntegrationEnabled(t *testing.T) {
    43  	tests := []struct {
    44  		description            string
    45  		giveHostGDPREnabled    bool
    46  		giveAccountGDPREnabled *bool
    47  		wantIntegrationEnabled bool
    48  	}{
    49  		{
    50  			description:            "Set at account level - use account setting false",
    51  			giveHostGDPREnabled:    true,
    52  			giveAccountGDPREnabled: &[]bool{false}[0],
    53  			wantIntegrationEnabled: false,
    54  		},
    55  		{
    56  			description:            "Set at account level - use account setting true",
    57  			giveHostGDPREnabled:    false,
    58  			giveAccountGDPREnabled: &[]bool{true}[0],
    59  			wantIntegrationEnabled: true,
    60  		},
    61  		{
    62  			description:            "Not set at account level - use host setting false",
    63  			giveHostGDPREnabled:    false,
    64  			giveAccountGDPREnabled: nil,
    65  			wantIntegrationEnabled: false,
    66  		},
    67  		{
    68  			description:            "Not set at account level - use host setting true",
    69  			giveHostGDPREnabled:    true,
    70  			giveAccountGDPREnabled: nil,
    71  			wantIntegrationEnabled: true,
    72  		},
    73  	}
    74  
    75  	for _, tt := range tests {
    76  		cfg := tcf2Config{
    77  			AccountConfig: config.AccountGDPR{
    78  				Enabled: tt.giveAccountGDPREnabled,
    79  			},
    80  			HostConfig: config.TCF2{
    81  				Enabled: tt.giveHostGDPREnabled,
    82  			},
    83  		}
    84  
    85  		result := cfg.ChannelEnabled(config.ChannelWeb)
    86  
    87  		assert.Equal(t, tt.wantIntegrationEnabled, result, tt.description)
    88  	}
    89  }
    90  
    91  func TestPurposeEnforced(t *testing.T) {
    92  	False := false
    93  	True := true
    94  
    95  	tests := []struct {
    96  		description                    string
    97  		givePurpose1HostEnforcement    bool
    98  		givePurpose1AccountEnforcement *bool
    99  		givePurpose2HostEnforcement    bool
   100  		givePurpose2AccountEnforcement *bool
   101  		givePurpose                    consentconstants.Purpose
   102  		wantEnforced                   bool
   103  	}{
   104  		{
   105  			description:                    "Purpose 1 set at account level - use account setting false",
   106  			givePurpose1HostEnforcement:    true,
   107  			givePurpose1AccountEnforcement: &False,
   108  			givePurpose:                    1,
   109  			wantEnforced:                   false,
   110  		},
   111  		{
   112  			description:                    "Purpose 1 set at account level - use account setting true",
   113  			givePurpose1HostEnforcement:    false,
   114  			givePurpose1AccountEnforcement: &True,
   115  			givePurpose:                    1,
   116  			wantEnforced:                   true,
   117  		},
   118  		{
   119  			description:                    "Purpose 1 not set at account level - use host setting false",
   120  			givePurpose1HostEnforcement:    false,
   121  			givePurpose1AccountEnforcement: nil,
   122  			givePurpose:                    1,
   123  			wantEnforced:                   false,
   124  		},
   125  		{
   126  			description:                    "Purpose 1 not set at account level - use host setting true",
   127  			givePurpose1HostEnforcement:    true,
   128  			givePurpose1AccountEnforcement: nil,
   129  			givePurpose:                    1,
   130  			wantEnforced:                   true,
   131  		},
   132  		{
   133  			description:                    "Some other purpose set at account level - use account setting true",
   134  			givePurpose2HostEnforcement:    false,
   135  			givePurpose2AccountEnforcement: &True,
   136  			givePurpose:                    2,
   137  			wantEnforced:                   true,
   138  		},
   139  	}
   140  
   141  	for _, tt := range tests {
   142  		cfg := tcf2Config{
   143  			AccountConfig: config.AccountGDPR{
   144  				Purpose1: config.AccountGDPRPurpose{
   145  					EnforcePurpose: tt.givePurpose1AccountEnforcement,
   146  				},
   147  				Purpose2: config.AccountGDPRPurpose{
   148  					EnforcePurpose: tt.givePurpose2AccountEnforcement,
   149  				},
   150  			},
   151  			HostConfig: config.TCF2{
   152  				Purpose1: config.TCF2Purpose{
   153  					EnforcePurpose: tt.givePurpose1HostEnforcement,
   154  				},
   155  				Purpose2: config.TCF2Purpose{
   156  					EnforcePurpose: tt.givePurpose2HostEnforcement,
   157  				},
   158  			},
   159  		}
   160  		MakeTCF2ConfigPurposeMaps(&cfg)
   161  
   162  		result := cfg.PurposeEnforced(consentconstants.Purpose(tt.givePurpose))
   163  
   164  		assert.Equal(t, tt.wantEnforced, result, tt.description)
   165  	}
   166  }
   167  
   168  func TestPurposeEnforcementAlgo(t *testing.T) {
   169  
   170  	tests := []struct {
   171  		description             string
   172  		givePurpose1HostAlgo    config.TCF2EnforcementAlgo
   173  		givePurpose1AccountAlgo config.TCF2EnforcementAlgo
   174  		givePurpose2HostAlgo    config.TCF2EnforcementAlgo
   175  		givePurpose2AccountAlgo config.TCF2EnforcementAlgo
   176  		givePurpose             consentconstants.Purpose
   177  		wantAlgo                config.TCF2EnforcementAlgo
   178  	}{
   179  		{
   180  			description:             "Purpose 1 set at account level - use account setting basic",
   181  			givePurpose1HostAlgo:    config.TCF2FullEnforcement,
   182  			givePurpose1AccountAlgo: config.TCF2BasicEnforcement,
   183  			givePurpose:             1,
   184  			wantAlgo:                config.TCF2BasicEnforcement,
   185  		},
   186  		{
   187  			description:             "Purpose 1 set at account level - use account setting full",
   188  			givePurpose1HostAlgo:    config.TCF2BasicEnforcement,
   189  			givePurpose1AccountAlgo: config.TCF2FullEnforcement,
   190  			givePurpose:             1,
   191  			wantAlgo:                config.TCF2FullEnforcement,
   192  		},
   193  		{
   194  			description:             "Purpose 1 not set at account level - use host setting basic",
   195  			givePurpose1HostAlgo:    config.TCF2BasicEnforcement,
   196  			givePurpose1AccountAlgo: config.TCF2UndefinedEnforcement,
   197  			givePurpose:             1,
   198  			wantAlgo:                config.TCF2BasicEnforcement,
   199  		},
   200  		{
   201  			description:             "Purpose 1 not set at account level - use host setting full",
   202  			givePurpose1HostAlgo:    config.TCF2FullEnforcement,
   203  			givePurpose1AccountAlgo: config.TCF2UndefinedEnforcement,
   204  			givePurpose:             1,
   205  			wantAlgo:                config.TCF2FullEnforcement,
   206  		},
   207  		{
   208  			description:             "Some other purpose set at account level - use account setting basic",
   209  			givePurpose2HostAlgo:    config.TCF2FullEnforcement,
   210  			givePurpose2AccountAlgo: config.TCF2BasicEnforcement,
   211  			givePurpose:             2,
   212  			wantAlgo:                config.TCF2BasicEnforcement,
   213  		},
   214  	}
   215  
   216  	for _, tt := range tests {
   217  		cfg := tcf2Config{
   218  			AccountConfig: config.AccountGDPR{
   219  				Purpose1: config.AccountGDPRPurpose{
   220  					EnforceAlgoID: tt.givePurpose1AccountAlgo,
   221  				},
   222  				Purpose2: config.AccountGDPRPurpose{
   223  					EnforceAlgoID: tt.givePurpose2AccountAlgo,
   224  				},
   225  			},
   226  			HostConfig: config.TCF2{
   227  				Purpose1: config.TCF2Purpose{
   228  					EnforceAlgoID: tt.givePurpose1HostAlgo,
   229  				},
   230  				Purpose2: config.TCF2Purpose{
   231  					EnforceAlgoID: tt.givePurpose2HostAlgo,
   232  				},
   233  			},
   234  		}
   235  		MakeTCF2ConfigPurposeMaps(&cfg)
   236  
   237  		result := cfg.PurposeEnforcementAlgo(consentconstants.Purpose(tt.givePurpose))
   238  
   239  		assert.Equal(t, tt.wantAlgo, result, tt.description)
   240  	}
   241  }
   242  
   243  func TestPurposeEnforcingVendors(t *testing.T) {
   244  	tests := []struct {
   245  		description                  string
   246  		givePurpose1HostEnforcing    bool
   247  		givePurpose1AccountEnforcing *bool
   248  		givePurpose2HostEnforcing    bool
   249  		givePurpose2AccountEnforcing *bool
   250  		givePurpose                  consentconstants.Purpose
   251  		wantEnforcing                bool
   252  	}{
   253  		{
   254  			description:                  "Purpose 1 set at account level - use account setting false",
   255  			givePurpose1HostEnforcing:    true,
   256  			givePurpose1AccountEnforcing: &[]bool{false}[0],
   257  			givePurpose:                  1,
   258  			wantEnforcing:                false,
   259  		},
   260  		{
   261  			description:                  "Purpose 1 set at account level - use account setting true",
   262  			givePurpose1HostEnforcing:    false,
   263  			givePurpose1AccountEnforcing: &[]bool{true}[0],
   264  			givePurpose:                  1,
   265  			wantEnforcing:                true,
   266  		},
   267  		{
   268  			description:                  "Purpose 1 not set at account level - use host setting false",
   269  			givePurpose1HostEnforcing:    false,
   270  			givePurpose1AccountEnforcing: nil,
   271  			givePurpose:                  1,
   272  			wantEnforcing:                false,
   273  		},
   274  		{
   275  			description:                  "Purpose 1 not set at account level - use host setting true",
   276  			givePurpose1HostEnforcing:    true,
   277  			givePurpose1AccountEnforcing: nil,
   278  			givePurpose:                  1,
   279  			wantEnforcing:                true,
   280  		},
   281  		{
   282  			description:                  "Some other purpose set at account level - use account setting true",
   283  			givePurpose2HostEnforcing:    false,
   284  			givePurpose2AccountEnforcing: &[]bool{true}[0],
   285  			givePurpose:                  2,
   286  			wantEnforcing:                true,
   287  		},
   288  	}
   289  
   290  	for _, tt := range tests {
   291  		cfg := tcf2Config{
   292  			AccountConfig: config.AccountGDPR{
   293  				Purpose1: config.AccountGDPRPurpose{
   294  					EnforceVendors: tt.givePurpose1AccountEnforcing,
   295  				},
   296  				Purpose2: config.AccountGDPRPurpose{
   297  					EnforceVendors: tt.givePurpose2AccountEnforcing,
   298  				},
   299  			},
   300  			HostConfig: config.TCF2{
   301  				Purpose1: config.TCF2Purpose{
   302  					EnforceVendors: tt.givePurpose1HostEnforcing,
   303  				},
   304  				Purpose2: config.TCF2Purpose{
   305  					EnforceVendors: tt.givePurpose2HostEnforcing,
   306  				},
   307  			},
   308  		}
   309  		MakeTCF2ConfigPurposeMaps(&cfg)
   310  
   311  		result := cfg.PurposeEnforcingVendors(consentconstants.Purpose(tt.givePurpose))
   312  
   313  		assert.Equal(t, tt.wantEnforcing, result, tt.description)
   314  	}
   315  }
   316  
   317  func TestPurposeVendorExceptions(t *testing.T) {
   318  	tests := []struct {
   319  		description                     string
   320  		givePurpose1HostExceptionMap    map[string]struct{}
   321  		givePurpose1AccountExceptionMap map[string]struct{}
   322  		givePurpose2HostExceptionMap    map[string]struct{}
   323  		givePurpose2AccountExceptionMap map[string]struct{}
   324  		givePurpose                     consentconstants.Purpose
   325  		wantExceptionMap                map[string]struct{}
   326  	}{
   327  		{
   328  			description:                     "Purpose 1 exception list set at account level - use empty account list",
   329  			givePurpose1HostExceptionMap:    map[string]struct{}{},
   330  			givePurpose1AccountExceptionMap: map[string]struct{}{},
   331  			givePurpose:                     1,
   332  			wantExceptionMap:                map[string]struct{}{},
   333  		},
   334  		{
   335  			description:                     "Purpose 1 exception list set at account level - use nonempty account list",
   336  			givePurpose1HostExceptionMap:    map[string]struct{}{},
   337  			givePurpose1AccountExceptionMap: map[string]struct{}{"appnexus": {}, "rubicon": {}},
   338  			givePurpose:                     1,
   339  			wantExceptionMap:                map[string]struct{}{"appnexus": {}, "rubicon": {}},
   340  		},
   341  		{
   342  			description:                     "Purpose 1 exception list not set at account level - use empty host list",
   343  			givePurpose1HostExceptionMap:    map[string]struct{}{},
   344  			givePurpose1AccountExceptionMap: nil,
   345  			givePurpose:                     1,
   346  			wantExceptionMap:                map[string]struct{}{},
   347  		},
   348  		{
   349  			description:                     "Purpose 1 exception list not set at account level - use nonempty host list",
   350  			givePurpose1HostExceptionMap:    map[string]struct{}{"appnexus": {}, "rubicon": {}},
   351  			givePurpose1AccountExceptionMap: nil,
   352  			givePurpose:                     1,
   353  			wantExceptionMap:                map[string]struct{}{"appnexus": {}, "rubicon": {}},
   354  		},
   355  		{
   356  			description:                     "Purpose 1 exception list not set at account level or host level",
   357  			givePurpose1HostExceptionMap:    nil,
   358  			givePurpose1AccountExceptionMap: nil,
   359  			givePurpose:                     1,
   360  			wantExceptionMap:                map[string]struct{}{},
   361  		},
   362  		{
   363  			description:                     "Some other purpose exception list set at account level",
   364  			givePurpose2HostExceptionMap:    map[string]struct{}{},
   365  			givePurpose2AccountExceptionMap: map[string]struct{}{"appnexus": {}, "rubicon": {}},
   366  			givePurpose:                     2,
   367  			wantExceptionMap:                map[string]struct{}{"appnexus": {}, "rubicon": {}},
   368  		},
   369  	}
   370  
   371  	for _, tt := range tests {
   372  		cfg := tcf2Config{
   373  			AccountConfig: config.AccountGDPR{
   374  				Purpose1: config.AccountGDPRPurpose{
   375  					VendorExceptionMap: tt.givePurpose1AccountExceptionMap,
   376  				},
   377  				Purpose2: config.AccountGDPRPurpose{
   378  					VendorExceptionMap: tt.givePurpose2AccountExceptionMap,
   379  				},
   380  			},
   381  			HostConfig: config.TCF2{
   382  				Purpose1: config.TCF2Purpose{
   383  					VendorExceptionMap: tt.givePurpose1HostExceptionMap,
   384  				},
   385  				Purpose2: config.TCF2Purpose{
   386  					VendorExceptionMap: tt.givePurpose2HostExceptionMap,
   387  				},
   388  			},
   389  		}
   390  		MakeTCF2ConfigPurposeMaps(&cfg)
   391  
   392  		result := cfg.PurposeVendorExceptions(consentconstants.Purpose(tt.givePurpose))
   393  
   394  		assert.Equal(t, tt.wantExceptionMap, result, tt.description)
   395  	}
   396  }
   397  
   398  func TestFeatureOneEnforced(t *testing.T) {
   399  	tests := []struct {
   400  		description          string
   401  		giveHostEnforcing    bool
   402  		giveAccountEnforcing *bool
   403  		wantEnforcing        bool
   404  		wantEnabled          bool
   405  	}{
   406  		{
   407  			description:          "Feature 1 enforced set at account level - use account setting false",
   408  			giveHostEnforcing:    true,
   409  			giveAccountEnforcing: &[]bool{false}[0],
   410  			wantEnforcing:        false,
   411  		},
   412  		{
   413  			description:          "Feature 1 enforced set at account level - use account setting true",
   414  			giveHostEnforcing:    false,
   415  			giveAccountEnforcing: &[]bool{true}[0],
   416  			wantEnforcing:        true,
   417  		},
   418  		{
   419  			description:          "Feature 1 enforced not set at account level - use host setting false",
   420  			giveHostEnforcing:    false,
   421  			giveAccountEnforcing: nil,
   422  			wantEnforcing:        false,
   423  		},
   424  		{
   425  			description:          "Feature 1 enforced not set at account level - use host setting true",
   426  			giveHostEnforcing:    true,
   427  			giveAccountEnforcing: nil,
   428  			wantEnforcing:        true,
   429  		},
   430  	}
   431  
   432  	for _, tt := range tests {
   433  		cfg := tcf2Config{
   434  			AccountConfig: config.AccountGDPR{
   435  				SpecialFeature1: config.AccountGDPRSpecialFeature{
   436  					Enforce: tt.giveAccountEnforcing,
   437  				},
   438  			},
   439  			HostConfig: config.TCF2{
   440  				SpecialFeature1: config.TCF2SpecialFeature{
   441  					Enforce: tt.giveHostEnforcing,
   442  				},
   443  			},
   444  		}
   445  
   446  		result := cfg.FeatureOneEnforced()
   447  
   448  		assert.Equal(t, tt.wantEnforcing, result, tt.description)
   449  	}
   450  }
   451  
   452  func TestFeatureOneVendorException(t *testing.T) {
   453  	tests := []struct {
   454  		description                   string
   455  		giveHostVendorExceptionMap    map[openrtb_ext.BidderName]struct{}
   456  		giveAccountVendorExceptionMap map[openrtb_ext.BidderName]struct{}
   457  		giveBidder                    openrtb_ext.BidderName
   458  		wantVendorException           bool
   459  	}{
   460  		{
   461  			description:                   "Feature 1 exception list set at account level - vendor found",
   462  			giveHostVendorExceptionMap:    map[openrtb_ext.BidderName]struct{}{},
   463  			giveAccountVendorExceptionMap: map[openrtb_ext.BidderName]struct{}{"appnexus": {}, "rubicon": {}},
   464  			giveBidder:                    "appnexus",
   465  			wantVendorException:           true,
   466  		},
   467  		{
   468  			description:                   "Feature 1 exception list set at account level - vendor not found",
   469  			giveHostVendorExceptionMap:    map[openrtb_ext.BidderName]struct{}{},
   470  			giveAccountVendorExceptionMap: map[openrtb_ext.BidderName]struct{}{"rubicon": {}},
   471  			giveBidder:                    "appnexus",
   472  			wantVendorException:           false,
   473  		},
   474  		{
   475  			description:                   "Feature 1 exception list not set at account level - vendor found in host list",
   476  			giveHostVendorExceptionMap:    map[openrtb_ext.BidderName]struct{}{"appnexus": {}, "rubicon": {}},
   477  			giveAccountVendorExceptionMap: nil,
   478  			giveBidder:                    "appnexus",
   479  			wantVendorException:           true,
   480  		},
   481  		{
   482  			description:                   "Feature 1 exception list not set at account level - vendor not found in host list",
   483  			giveHostVendorExceptionMap:    map[openrtb_ext.BidderName]struct{}{"rubicon": {}},
   484  			giveAccountVendorExceptionMap: nil,
   485  			giveBidder:                    "appnexus",
   486  			wantVendorException:           false,
   487  		},
   488  		{
   489  			description:                   "Feature 1 exception list not set at account level or host level - vendor not found",
   490  			giveHostVendorExceptionMap:    nil,
   491  			giveAccountVendorExceptionMap: nil,
   492  			giveBidder:                    "appnexus",
   493  			wantVendorException:           false,
   494  		},
   495  	}
   496  
   497  	for _, tt := range tests {
   498  		cfg := tcf2Config{
   499  			AccountConfig: config.AccountGDPR{
   500  				SpecialFeature1: config.AccountGDPRSpecialFeature{
   501  					VendorExceptionMap: tt.giveAccountVendorExceptionMap,
   502  				},
   503  			},
   504  			HostConfig: config.TCF2{
   505  				SpecialFeature1: config.TCF2SpecialFeature{
   506  					VendorExceptionMap: tt.giveHostVendorExceptionMap,
   507  				},
   508  			},
   509  		}
   510  
   511  		result := cfg.FeatureOneVendorException(tt.giveBidder)
   512  
   513  		assert.Equal(t, tt.wantVendorException, result, tt.description)
   514  	}
   515  }
   516  
   517  func TestPurposeOneTreatmentEnabled(t *testing.T) {
   518  	tests := []struct {
   519  		description        string
   520  		giveHostEnabled    bool
   521  		giveAccountEnabled *bool
   522  		wantEnabled        bool
   523  	}{
   524  		{
   525  			description:        "Purpose 1 treatment enabled set at account level - use account setting false",
   526  			giveHostEnabled:    true,
   527  			giveAccountEnabled: &[]bool{false}[0],
   528  			wantEnabled:        false,
   529  		},
   530  		{
   531  			description:        "Purpose 1 treatment enabled set at account level - use account setting true",
   532  			giveHostEnabled:    false,
   533  			giveAccountEnabled: &[]bool{true}[0],
   534  			wantEnabled:        true,
   535  		},
   536  		{
   537  			description:        "Purpose 1 treatment enabled not set at account level - use host setting false",
   538  			giveHostEnabled:    false,
   539  			giveAccountEnabled: nil,
   540  			wantEnabled:        false,
   541  		},
   542  		{
   543  			description:        "Purpose 1 treatment enabled not set at account level - use host setting true",
   544  			giveHostEnabled:    true,
   545  			giveAccountEnabled: nil,
   546  			wantEnabled:        true,
   547  		},
   548  	}
   549  
   550  	for _, tt := range tests {
   551  		cfg := tcf2Config{
   552  			AccountConfig: config.AccountGDPR{
   553  				PurposeOneTreatment: config.AccountGDPRPurposeOneTreatment{
   554  					Enabled: tt.giveAccountEnabled,
   555  				},
   556  			},
   557  			HostConfig: config.TCF2{
   558  				PurposeOneTreatment: config.TCF2PurposeOneTreatment{
   559  					Enabled: tt.giveHostEnabled,
   560  				},
   561  			},
   562  		}
   563  
   564  		result := cfg.PurposeOneTreatmentEnabled()
   565  
   566  		assert.Equal(t, tt.wantEnabled, result, tt.description)
   567  	}
   568  }
   569  
   570  func TestPurposeOneTreatmentAllowed(t *testing.T) {
   571  	tests := []struct {
   572  		description              string
   573  		giveHostAccessAllowed    bool
   574  		giveAccountAccessAllowed *bool
   575  		wantAccessAllowed        bool
   576  	}{
   577  		{
   578  			description:              "Purpose 1 treatment access allowed set at account level - use account setting false",
   579  			giveHostAccessAllowed:    true,
   580  			giveAccountAccessAllowed: &[]bool{false}[0],
   581  			wantAccessAllowed:        false,
   582  		},
   583  		{
   584  			description:              "Purpose 1 treatment access allowed set at account level - use account setting true",
   585  			giveHostAccessAllowed:    false,
   586  			giveAccountAccessAllowed: &[]bool{true}[0],
   587  			wantAccessAllowed:        true,
   588  		},
   589  		{
   590  			description:              "Purpose 1 treatment access allowed not set at account level - use host setting false",
   591  			giveHostAccessAllowed:    false,
   592  			giveAccountAccessAllowed: nil,
   593  			wantAccessAllowed:        false,
   594  		},
   595  		{
   596  			description:              "Purpose 1 treatment access allowed not set at account level - use host setting true",
   597  			giveHostAccessAllowed:    true,
   598  			giveAccountAccessAllowed: nil,
   599  			wantAccessAllowed:        true,
   600  		},
   601  	}
   602  
   603  	for _, tt := range tests {
   604  		cfg := tcf2Config{
   605  			AccountConfig: config.AccountGDPR{
   606  				PurposeOneTreatment: config.AccountGDPRPurposeOneTreatment{
   607  					AccessAllowed: tt.giveAccountAccessAllowed,
   608  				},
   609  			},
   610  			HostConfig: config.TCF2{
   611  				PurposeOneTreatment: config.TCF2PurposeOneTreatment{
   612  					AccessAllowed: tt.giveHostAccessAllowed,
   613  				},
   614  			},
   615  		}
   616  
   617  		result := cfg.PurposeOneTreatmentAccessAllowed()
   618  
   619  		assert.Equal(t, tt.wantAccessAllowed, result, tt.description)
   620  	}
   621  }
   622  
   623  func TestBasicEnforcementVendors(t *testing.T) {
   624  	tests := []struct {
   625  		description               string
   626  		giveAccountBasicVendorMap map[string]struct{}
   627  		wantBasicVendorMap        map[string]struct{}
   628  	}{
   629  		{
   630  			description:               "Purpose 1 basic exception vendor list not set at account level",
   631  			giveAccountBasicVendorMap: nil,
   632  			wantBasicVendorMap:        map[string]struct{}{},
   633  		},
   634  		{
   635  			description:               "Purpose 1 basic exception vendor list set at account level as empty list",
   636  			giveAccountBasicVendorMap: map[string]struct{}{},
   637  			wantBasicVendorMap:        map[string]struct{}{},
   638  		},
   639  		{
   640  			description:               "Purpose 1 basic exception vendor list not set at account level as nonempty list",
   641  			giveAccountBasicVendorMap: map[string]struct{}{"appnexus": {}, "rubicon": {}},
   642  			wantBasicVendorMap:        map[string]struct{}{"appnexus": {}, "rubicon": {}},
   643  		},
   644  	}
   645  
   646  	for _, tt := range tests {
   647  		cfg := tcf2Config{
   648  			AccountConfig: config.AccountGDPR{
   649  				BasicEnforcementVendorsMap: tt.giveAccountBasicVendorMap,
   650  			},
   651  		}
   652  		MakeTCF2ConfigPurposeMaps(&cfg)
   653  
   654  		result := cfg.BasicEnforcementVendors()
   655  
   656  		assert.Equal(t, tt.wantBasicVendorMap, result, tt.description)
   657  	}
   658  }