/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 7 ĠD uck Duck Go Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . duck duck go . app . tracker detection Ċ Ċ import Ġcom . duck duck go . app . tracker detection . model . Disconnect Tracker Ċ import Ġcom . duck duck go . app . tracker detection . model . ResourceType Ċ import Ġorg . junit . Assert . assertFalse Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Test ĊĊ Ċ class ĠDis connect Client Instrumentation Test Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval Ġcategory B anned Ġ= Ġ" Social " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval Ġcategory Allowed Ġ= Ġ" Content " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval Ġnetwork Ġ= Ġ" Network " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval Ġnetwork Url Ġ= Ġ" http :// www . network . com /" ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval Ġdocument Url Ġ= Ġ" http :// example . com / index . htm " ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġresource Type Ġ= ĠResource Type . UNKNOWN ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Is AT rack er In Blocked Category Then Matches IsTrue () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( Disconnect Tracker (" tracker . com ", Ġcategory B anned , Ġnetwork , Ġnetwork Url )) ĊĠĠĠĠĠĠĠ Ġval Ġtest ee Ġ= ĠDis connect Client ( Client . Client Name . DIS CONNECT , Ġdata ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( test ee . matches (" http :// tracker . com / script . js ", Ġdocument Url , Ġresource Type )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Is AT rack er Outside Blocked Category Then Matches IsFalse () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( Disconnect Tracker (" tracker . com ", Ġcategory Allowed , Ġnetwork , Ġnetwork Url )) ĊĠĠĠĠĠĠĠ Ġval Ġtest ee Ġ= ĠDis connect Client ( Client . Client Name . DIS CONNECT , Ġdata ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . matches (" http :// tracker . com / script . js ", Ġdocument Url , Ġresource Type )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url IsNot AT rack er Then Matches IsFalse () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( Disconnect Tracker (" tracker . com ", Ġcategory B anned , Ġnetwork , Ġnetwork Url )) ĊĠĠĠĠĠĠĠ Ġval Ġtest ee Ġ= ĠDis connect Client ( Client . Client Name . DIS CONNECT , Ġdata ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . matches (" http :// non tracker . com / script . js ", Ġdocument Url , Ġresource Type )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Is AS ub domain Of AT rack er Then Matches IsTrue () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( Disconnect Tracker (" tracker . com ", Ġcategory B anned , Ġnetwork , Ġnetwork Url )) ĊĠĠĠĠĠĠĠ Ġval Ġtest ee Ġ= ĠDis connect Client ( Client . Client Name . DIS CONNECT , Ġdata ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( test ee . matches (" http :// sub dom ian . tracker . com / script . js ", Ġdocument Url , Ġresource Type )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Is AP arent Domain Of AT rack er Then Matches IsFalse () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( Disconnect Tracker (" subdomain . tracker . com ", Ġcategory B anned , Ġnetwork , Ġnetwork Url )) ĊĠĠĠĠĠĠĠ Ġval Ġtest ee Ġ= ĠDis connect Client ( Client . Client Name . DIS CONNECT , Ġdata ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . matches (" http :// tracker . com / script . js ", Ġdocument Url , Ġresource Type )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Url Cont aints But IsNot Sub domain Of AT rack er Then Matches IsFalse () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠlistOf ( Disconnect Tracker (" tracker . com ", Ġcategory B anned , Ġnetwork , Ġnetwork Url )) ĊĠĠĠĠĠĠĠ Ġval Ġtest ee Ġ= ĠDis connect Client ( Client . Client Name . DIS CONNECT , Ġdata ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( test ee . matches (" http :// not subdomain of tracker . com ", Ġdocument Url , Ġresource Type )) ĊĠĠĠ Ġ} Ċ }