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

Default TCF1 GVL in anticipation of IAB no longer hosting the v1 GVL #1433

Merged
merged 3 commits into from
Aug 12, 2020

Conversation

hhhjort
Copy link
Collaborator

@hhhjort hhhjort commented Aug 7, 2020

No description provided.

@SyntaxNode SyntaxNode changed the title Default TCF1 GLV in anticipation of IAB no longer hosting the v1 GLV Default TCF1 GVL in anticipation of IAB no longer hosting the v1 GVL Aug 10, 2020
config/config.go Outdated
// TCF1 defines the TCF1 specific configurations for GDPR
type TCF1 struct {
FetchGVL bool `mapstructure:"fetch_gvl"`
DefaultGVLPath string `mapstructure:"default_gvl_path"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The word "Default" in a config file leads me to think this might be, well, a default value and not one necessarily provided by the host. Consider renaming to FallbackGVLPath.

@@ -27,8 +27,27 @@ type saveVendors func(uint16, api.VendorList)
// Nothing in this file is exported. Public APIs can be found in gdpr.go

func newVendorListFetcher(initCtx context.Context, cfg config.GDPR, client *http.Client, urlMaker func(uint16, uint8) string, TCFVer uint8) func(ctx context.Context, id uint16) (vendorlist.VendorList, error) {
var defaultVL api.VendorList = nil

if TCFVer == tCF1 && len(cfg.TCF1.DefaultGVLPath) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting this block to it's own method.

if TCFVer == tCF1 && len(cfg.TCF1.DefaultGVLPath) > 0 {
defaultVLbody, err := ioutil.ReadFile(cfg.TCF1.DefaultGVLPath)
if err != nil {
glog.Fatalf("Error reading from file %s: %v", cfg.TCF1.DefaultGVLPath, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this method return an error as well if we can't load the default GVL? Same with the result of the ParseEagerly call.

gdpr/vendorlist-fetching_test.go Show resolved Hide resolved
if TCFVer == tCF1 && len(cfg.TCF1.DefaultGVLPath) > 0 {
defaultVLbody, err := ioutil.ReadFile(cfg.TCF1.DefaultGVLPath)
if err != nil {
glog.Fatalf("Error reading from file %s: %v", cfg.TCF1.DefaultGVLPath, err)
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 a test case for a failed file read?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't have a fatal error at this point if I want to test for that, as won't glog.Fatalf() mean that the test will fail at that point?

Copy link
Contributor

@mansinahar mansinahar left a comment

Choose a reason for hiding this comment

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

LGTM in general! Only thing I'd say is that if possible we should consider converting the tests into table test format to reduce redundant setup and assertion code.

purposes: []int{2},
},
})
server := httptest.NewServer(http.HandlerFunc(mockServer(1, map[int]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please use a var to hold the list version that we use here when creating the mockServer (for this and the tests above) and then later to assert that same version? It just helps understand better what those integer values represent while reading the tests.

@SyntaxNode SyntaxNode merged commit 549cc79 into master Aug 12, 2020
@SyntaxNode SyntaxNode deleted the tcf1-gvl branch March 13, 2023 13:53
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.

3 participants