mirror of
https://github.com/cubixle/iabtcfv2.git
synced 2026-04-24 23:04:44 +01:00
Import "github.com/SirDataFR/iab-tcf-v2" for tests
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
package iabtcf
|
package iabtcf_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
iabtcf "github.com/SirDataFR/iab-tcf-v2"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecode(t *testing.T) {
|
func TestDecode(t *testing.T) {
|
||||||
str := "COxR03kOxR1CqBcABCENAgCMAP_AAH_AAAqIF3EXySoGY2thI2YVFxBEIYwfJxyigMgChgQIsSwNQIeFLBoGLiAAHBGYJAQAGBAEEACBAQIkHGBMCQAAgAgBiRCMQEGMCzNIBIBAggEbY0FACCVmHkHSmZCY7064O__QLuIJEFQMAkSBAIACLECIQwAQDiAAAYAlAAABAhIaAAgIWBQEeAAAACAwAAgAAABBAAACAAQAAICIAAABAAAgAiAQAAAAGgIQAACBABACRIAAAEANCAAgiCEAQg4EAo4AAA.IF3EXySoGY2tho2YVFzBEIYwfJxyigMgShgQIsS0NQIeFLBoGPiAAHBGYJAQAGBAkkACBAQIsHGBMCQABgAgRiRCMQEGMDzNIBIBAggkbY0FACCVmnkHS3ZCY70-6u__QA.elAAAAAAAWA"
|
str := "COxR03kOxR1CqBcABCENAgCMAP_AAH_AAAqIF3EXySoGY2thI2YVFxBEIYwfJxyigMgChgQIsSwNQIeFLBoGLiAAHBGYJAQAGBAEEACBAQIkHGBMCQAAgAgBiRCMQEGMCzNIBIBAggEbY0FACCVmHkHSmZCY7064O__QLuIJEFQMAkSBAIACLECIQwAQDiAAAYAlAAABAhIaAAgIWBQEeAAAACAwAAgAAABBAAACAAQAAICIAAABAAAgAiAQAAAAGgIQAACBABACRIAAAEANCAAgiCEAQg4EAo4AAA.IF3EXySoGY2tho2YVFzBEIYwfJxyigMgShgQIsS0NQIeFLBoGPiAAHBGYJAQAGBAkkACBAQIsHGBMCQABgAgRiRCMQEGMDzNIBIBAggkbY0FACCVmnkHS3ZCY70-6u__QA.elAAAAAAAWA"
|
||||||
|
|
||||||
data, err := Decode(str)
|
data, err := iabtcf.Decode(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("TC String should be decoded without error: %s", err)
|
t.Errorf("TC String should be decoded without error: %s", err)
|
||||||
return
|
return
|
||||||
@@ -27,7 +28,7 @@ func TestDecode(t *testing.T) {
|
|||||||
func TestDecodeInvalid(t *testing.T) {
|
func TestDecodeInvalid(t *testing.T) {
|
||||||
str := "IF3EXySoGY2tho2YVFzBEIYwfJxyigMgShgQIsS0NQIeFLBoGPiAAHBGYJAQAGBAkkACBAQIsHGBMCQABgAgRiRCMQEGMDzNIBIBAggkbY0FACCVmnkHS3ZCY70-6u__QA.elAAAAAAAWA"
|
str := "IF3EXySoGY2tho2YVFzBEIYwfJxyigMgShgQIsS0NQIeFLBoGPiAAHBGYJAQAGBAkkACBAQIsHGBMCQABgAgRiRCMQEGMDzNIBIBAggkbY0FACCVmnkHS3ZCY70-6u__QA.elAAAAAAAWA"
|
||||||
|
|
||||||
_, err := Decode(str)
|
_, err := iabtcf.Decode(str)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("TC String should not be decoded: %s", err)
|
t.Errorf("TC String should not be decoded: %s", err)
|
||||||
return
|
return
|
||||||
@@ -37,12 +38,12 @@ func TestDecodeInvalid(t *testing.T) {
|
|||||||
func TestDecodeCoreString(t *testing.T) {
|
func TestDecodeCoreString(t *testing.T) {
|
||||||
str := "COxR03kOxR1CqBcABCENAgCMAP_AAH_AAAqIF3EXySoGY2thI2YVFxBEIYwfJxyigMgChgQIsSwNQIeFLBoGLiAAHBGYJAQAGBAEEACBAQIkHGBMCQAAgAgBiRCMQEGMCzNIBIBAggEbY0FACCVmHkHSmZCY7064O__QLuIJEFQMAkSBAIACLECIQwAQDiAAAYAlAAABAhIaAAgIWBQEeAAAACAwAAgAAABBAAACAAQAAICIAAABAAAgAiAQAAAAGgIQAACBABACRIAAAEANCAAgiCEAQg4EAo4AAA"
|
str := "COxR03kOxR1CqBcABCENAgCMAP_AAH_AAAqIF3EXySoGY2thI2YVFxBEIYwfJxyigMgChgQIsSwNQIeFLBoGLiAAHBGYJAQAGBAEEACBAQIkHGBMCQAAgAgBiRCMQEGMCzNIBIBAggEbY0FACCVmHkHSmZCY7064O__QLuIJEFQMAkSBAIACLECIQwAQDiAAAYAlAAABAhIaAAgIWBQEeAAAACAwAAgAAABBAAACAAQAAICIAAABAAAgAiAQAAAAGgIQAACBABACRIAAAEANCAAgiCEAQg4EAo4AAA"
|
||||||
|
|
||||||
if DecodeSegmentType(str) != 0 {
|
if iabtcf.DecodeSegmentType(str) != 0 {
|
||||||
t.Errorf("Segment type should be 0")
|
t.Errorf("Segment type should be 0")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
segment, err := DecodeCoreString(str)
|
segment, err := iabtcf.DecodeCoreString(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Segment should be decoded without error: %s", err)
|
t.Errorf("Segment should be decoded without error: %s", err)
|
||||||
return
|
return
|
||||||
@@ -62,12 +63,12 @@ func TestDecodeCoreString(t *testing.T) {
|
|||||||
func TestDecodeDisclosedVendors(t *testing.T) {
|
func TestDecodeDisclosedVendors(t *testing.T) {
|
||||||
str := "IF3EXySoGY2tho2YVFzBEIYwfJxyigMgShgQIsS0NQIeFLBoGPiAAHBGYJAQAGBAkkACBAQIsHGBMCQABgAgRiRCMQEGMDzNIBIBAggkbY0FACCVmnkHS3ZCY70-6u__QA"
|
str := "IF3EXySoGY2tho2YVFzBEIYwfJxyigMgShgQIsS0NQIeFLBoGPiAAHBGYJAQAGBAkkACBAQIsHGBMCQABgAgRiRCMQEGMDzNIBIBAggkbY0FACCVmnkHS3ZCY70-6u__QA"
|
||||||
|
|
||||||
if DecodeSegmentType(str) != 1 {
|
if iabtcf.DecodeSegmentType(str) != 1 {
|
||||||
t.Errorf("Segment type should be 1")
|
t.Errorf("Segment type should be 1")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
segment, err := DecodeDisclosedVendors(str)
|
segment, err := iabtcf.DecodeDisclosedVendors(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Segment should be decoded without error: %s", err)
|
t.Errorf("Segment should be decoded without error: %s", err)
|
||||||
return
|
return
|
||||||
@@ -97,12 +98,12 @@ func TestDecodeDisclosedVendors(t *testing.T) {
|
|||||||
func TestDecodeAllowedVendors(t *testing.T) {
|
func TestDecodeAllowedVendors(t *testing.T) {
|
||||||
str := "QF3QAgABAA1A"
|
str := "QF3QAgABAA1A"
|
||||||
|
|
||||||
if DecodeSegmentType(str) != 2 {
|
if iabtcf.DecodeSegmentType(str) != 2 {
|
||||||
t.Errorf("Segment type should be 2")
|
t.Errorf("Segment type should be 2")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
segment, err := DecodeAllowedVendors(str)
|
segment, err := iabtcf.DecodeAllowedVendors(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Segment should be decoded without error: %s", err)
|
t.Errorf("Segment should be decoded without error: %s", err)
|
||||||
return
|
return
|
||||||
@@ -132,12 +133,12 @@ func TestDecodeAllowedVendors(t *testing.T) {
|
|||||||
func TestDecodePublisherTC(t *testing.T) {
|
func TestDecodePublisherTC(t *testing.T) {
|
||||||
str := "elAAAAAAAWA"
|
str := "elAAAAAAAWA"
|
||||||
|
|
||||||
if DecodeSegmentType(str) != 3 {
|
if iabtcf.DecodeSegmentType(str) != 3 {
|
||||||
t.Errorf("Segment type should be 3")
|
t.Errorf("Segment type should be 3")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
segment, err := DecodePubllisherTC(str)
|
segment, err := iabtcf.DecodePubllisherTC(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Segment should be decoded without error: %s", err)
|
t.Errorf("Segment should be decoded without error: %s", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package iabtcf
|
package iabtcf_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
iabtcf "github.com/SirDataFR/iab-tcf-v2"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEncode(t *testing.T) {
|
func TestEncode(t *testing.T) {
|
||||||
str := "COxSKBCOxSKCCBcABCENAgCMAPzAAEPAAAqIDaQBQAMgAgABqAR0A2gDaQAwAMgAgANoAAA.IDaQBQAMgAgABqAR0A2g.QF3QAgABAA1A.eEAAAAAAAUA"
|
str := "COxSKBCOxSKCCBcABCENAgCMAPzAAEPAAAqIDaQBQAMgAgABqAR0A2gDaQAwAMgAgANoAAA.IDaQBQAMgAgABqAR0A2g.QF3QAgABAA1A.eEAAAAAAAUA"
|
||||||
data := &TCData{
|
data := &iabtcf.TCData{
|
||||||
CoreString: &CoreString{
|
CoreString: &iabtcf.CoreString{
|
||||||
Version: 2,
|
Version: 2,
|
||||||
Created: timeFromDeciSeconds(15859228738),
|
Created: timeFromDeciSeconds(15859228738),
|
||||||
LastUpdated: timeFromDeciSeconds(15859228802),
|
LastUpdated: timeFromDeciSeconds(15859228802),
|
||||||
@@ -47,7 +48,7 @@ func TestEncode(t *testing.T) {
|
|||||||
IsRangeEncoding: true,
|
IsRangeEncoding: true,
|
||||||
VendorsConsent: map[int]bool{},
|
VendorsConsent: map[int]bool{},
|
||||||
NumEntries: 5,
|
NumEntries: 5,
|
||||||
RangeEntries: []*RangeEntry{
|
RangeEntries: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 25,
|
StartVendorID: 25,
|
||||||
EndVendorID: 25,
|
EndVendorID: 25,
|
||||||
@@ -73,7 +74,7 @@ func TestEncode(t *testing.T) {
|
|||||||
IsRangeEncodingLI: true,
|
IsRangeEncodingLI: true,
|
||||||
VendorsLITransparency: map[int]bool{},
|
VendorsLITransparency: map[int]bool{},
|
||||||
NumEntriesLI: 3,
|
NumEntriesLI: 3,
|
||||||
RangeEntriesLI: []*RangeEntry{
|
RangeEntriesLI: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 25,
|
StartVendorID: 25,
|
||||||
EndVendorID: 25,
|
EndVendorID: 25,
|
||||||
@@ -89,12 +90,12 @@ func TestEncode(t *testing.T) {
|
|||||||
},
|
},
|
||||||
NumPubRestrictions: 0,
|
NumPubRestrictions: 0,
|
||||||
},
|
},
|
||||||
DisclosedVendors: &DisclosedVendors{
|
DisclosedVendors: &iabtcf.DisclosedVendors{
|
||||||
SegmentType: 1,
|
SegmentType: 1,
|
||||||
MaxVendorId: 436,
|
MaxVendorId: 436,
|
||||||
IsRangeEncoding: true,
|
IsRangeEncoding: true,
|
||||||
NumEntries: 5,
|
NumEntries: 5,
|
||||||
RangeEntries: []*RangeEntry{
|
RangeEntries: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 25,
|
StartVendorID: 25,
|
||||||
EndVendorID: 25,
|
EndVendorID: 25,
|
||||||
@@ -117,12 +118,12 @@ func TestEncode(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AllowedVendors: &AllowedVendors{
|
AllowedVendors: &iabtcf.AllowedVendors{
|
||||||
SegmentType: 2,
|
SegmentType: 2,
|
||||||
MaxVendorId: 750,
|
MaxVendorId: 750,
|
||||||
IsRangeEncoding: true,
|
IsRangeEncoding: true,
|
||||||
NumEntries: 2,
|
NumEntries: 2,
|
||||||
RangeEntries: []*RangeEntry{
|
RangeEntries: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 2,
|
StartVendorID: 2,
|
||||||
EndVendorID: 2,
|
EndVendorID: 2,
|
||||||
@@ -133,7 +134,7 @@ func TestEncode(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
PublisherTC: &PublisherTC{
|
PublisherTC: &iabtcf.PublisherTC{
|
||||||
SegmentType: 3,
|
SegmentType: 3,
|
||||||
PubPurposesConsent: map[int]bool{
|
PubPurposesConsent: map[int]bool{
|
||||||
1: true,
|
1: true,
|
||||||
@@ -157,7 +158,7 @@ func TestEncode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
func TestEncodeCoreString(t *testing.T) {
|
func TestEncodeCoreString(t *testing.T) {
|
||||||
str := "COxSKBCOxSKCCBcABCENAgCMAPzAAEPAAAqIDaQBQAMgAgABqAR0A2gDaQAwAMgAgANoAAA"
|
str := "COxSKBCOxSKCCBcABCENAgCMAPzAAEPAAAqIDaQBQAMgAgABqAR0A2gDaQAwAMgAgANoAAA"
|
||||||
segment := &CoreString{
|
segment := &iabtcf.CoreString{
|
||||||
Version: 2,
|
Version: 2,
|
||||||
Created: timeFromDeciSeconds(15859228738),
|
Created: timeFromDeciSeconds(15859228738),
|
||||||
LastUpdated: timeFromDeciSeconds(15859228802),
|
LastUpdated: timeFromDeciSeconds(15859228802),
|
||||||
@@ -196,7 +197,7 @@ func TestEncodeCoreString(t *testing.T) {
|
|||||||
IsRangeEncoding: true,
|
IsRangeEncoding: true,
|
||||||
VendorsConsent: map[int]bool{},
|
VendorsConsent: map[int]bool{},
|
||||||
NumEntries: 5,
|
NumEntries: 5,
|
||||||
RangeEntries: []*RangeEntry{
|
RangeEntries: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 25,
|
StartVendorID: 25,
|
||||||
EndVendorID: 25,
|
EndVendorID: 25,
|
||||||
@@ -222,7 +223,7 @@ func TestEncodeCoreString(t *testing.T) {
|
|||||||
IsRangeEncodingLI: true,
|
IsRangeEncodingLI: true,
|
||||||
VendorsLITransparency: map[int]bool{},
|
VendorsLITransparency: map[int]bool{},
|
||||||
NumEntriesLI: 3,
|
NumEntriesLI: 3,
|
||||||
RangeEntriesLI: []*RangeEntry{
|
RangeEntriesLI: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 25,
|
StartVendorID: 25,
|
||||||
EndVendorID: 25,
|
EndVendorID: 25,
|
||||||
@@ -247,12 +248,12 @@ func TestEncodeCoreString(t *testing.T) {
|
|||||||
|
|
||||||
func TestEncodeDisclosedVendors(t *testing.T) {
|
func TestEncodeDisclosedVendors(t *testing.T) {
|
||||||
str := "IDaQBQAMgAgABqAR0A2g"
|
str := "IDaQBQAMgAgABqAR0A2g"
|
||||||
segment := &DisclosedVendors{
|
segment := &iabtcf.DisclosedVendors{
|
||||||
SegmentType: 1,
|
SegmentType: 1,
|
||||||
MaxVendorId: 436,
|
MaxVendorId: 436,
|
||||||
IsRangeEncoding: true,
|
IsRangeEncoding: true,
|
||||||
NumEntries: 5,
|
NumEntries: 5,
|
||||||
RangeEntries: []*RangeEntry{
|
RangeEntries: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 25,
|
StartVendorID: 25,
|
||||||
EndVendorID: 25,
|
EndVendorID: 25,
|
||||||
@@ -284,12 +285,12 @@ func TestEncodeDisclosedVendors(t *testing.T) {
|
|||||||
|
|
||||||
func TestEncodeAllowedVendors(t *testing.T) {
|
func TestEncodeAllowedVendors(t *testing.T) {
|
||||||
str := "QF3QAgABAA1A"
|
str := "QF3QAgABAA1A"
|
||||||
segment := &AllowedVendors{
|
segment := &iabtcf.AllowedVendors{
|
||||||
SegmentType: 2,
|
SegmentType: 2,
|
||||||
MaxVendorId: 750,
|
MaxVendorId: 750,
|
||||||
IsRangeEncoding: true,
|
IsRangeEncoding: true,
|
||||||
NumEntries: 2,
|
NumEntries: 2,
|
||||||
RangeEntries: []*RangeEntry{
|
RangeEntries: []*iabtcf.RangeEntry{
|
||||||
{
|
{
|
||||||
StartVendorID: 2,
|
StartVendorID: 2,
|
||||||
EndVendorID: 2,
|
EndVendorID: 2,
|
||||||
@@ -309,7 +310,7 @@ func TestEncodeAllowedVendors(t *testing.T) {
|
|||||||
|
|
||||||
func TestEncodePublisherTC(t *testing.T) {
|
func TestEncodePublisherTC(t *testing.T) {
|
||||||
str := "eEAAAAAAAUA"
|
str := "eEAAAAAAAUA"
|
||||||
segment := &PublisherTC{
|
segment := &iabtcf.PublisherTC{
|
||||||
SegmentType: 3,
|
SegmentType: 3,
|
||||||
PubPurposesConsent: map[int]bool{
|
PubPurposesConsent: map[int]bool{
|
||||||
1: true,
|
1: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user