-
Notifications
You must be signed in to change notification settings - Fork 762
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
Conversation
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"` |
There was a problem hiding this comment.
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
.
gdpr/vendorlist-fetching.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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.
gdpr/vendorlist-fetching.go
Outdated
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) |
There was a problem hiding this comment.
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.go
Outdated
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this 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{ |
There was a problem hiding this comment.
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.
No description provided.