@@ -927,6 +927,49 @@ func TestParseVideoRequestWithoutUserAgentAndEmptyHeader(t *testing.T) {
927
927
928
928
}
929
929
930
+ func TestParseVideoRequestWithEncodedUserAgentInHeader (t * testing.T ) {
931
+ ex := & mockExchangeVideo {}
932
+ reqData , err := ioutil .ReadFile ("sample-requests/video/video_valid_sample_without_device_user_agent.json" )
933
+ if err != nil {
934
+ t .Fatalf ("Failed to fetch a valid request: %v" , err )
935
+ }
936
+
937
+ uaEncoded := "Mozilla%2F5.0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010_14_6%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F78.0.3904.87%20Safari%2F537.36"
938
+ uaDecoded := "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36"
939
+
940
+ headers := http.Header {}
941
+ headers .Add ("User-Agent" , uaEncoded )
942
+
943
+ deps := mockDeps (t , ex )
944
+ req , valErr , podErr := deps .parseVideoRequest (reqData , headers )
945
+
946
+ assert .Equal (t , uaDecoded , req .Device .UA , "Device.ua should be taken from request header" )
947
+ assert .Equal (t , []error (nil ), valErr , "No validation errors should be returned" )
948
+ assert .Equal (t , make ([]PodError , 0 ), podErr , "No pod errors should be returned" )
949
+
950
+ }
951
+
952
+ func TestParseVideoRequestWithDecodedUserAgentInHeader (t * testing.T ) {
953
+ ex := & mockExchangeVideo {}
954
+ reqData , err := ioutil .ReadFile ("sample-requests/video/video_valid_sample_without_device_user_agent.json" )
955
+ if err != nil {
956
+ t .Fatalf ("Failed to fetch a valid request: %v" , err )
957
+ }
958
+
959
+ uaDecoded := "Mozilla/5.0+(Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36"
960
+
961
+ headers := http.Header {}
962
+ headers .Add ("User-Agent" , uaDecoded )
963
+
964
+ deps := mockDeps (t , ex )
965
+ req , valErr , podErr := deps .parseVideoRequest (reqData , headers )
966
+
967
+ assert .Equal (t , uaDecoded , req .Device .UA , "Device.ua should be taken from request header" )
968
+ assert .Equal (t , []error (nil ), valErr , "No validation errors should be returned" )
969
+ assert .Equal (t , make ([]PodError , 0 ), podErr , "No pod errors should be returned" )
970
+
971
+ }
972
+
930
973
func TestHandleErrorDebugLog (t * testing.T ) {
931
974
vo := analytics.VideoObject {
932
975
Status : 200 ,
0 commit comments