AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Functions | Variables
DavsClientTest.cpp File Reference
#include <AVSCommon/Utils/FileSystem/FileSystemUtils.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <rapidjson/document.h>
#include <chrono>
#include <memory>
#include <thread>
#include "AuthDelegateMock.h"
#include "CurlWrapperMock.h"
#include "DavsServiceMock.h"
#include "TestUtil.h"
#include "acsdkAssetsCommon/Base64Url.h"
#include "acsdkDavsClient/DavsEndpointHandlerV3.h"
#include "acsdkDavsClient/DavsHandler.h"
Include dependency graph for DavsClientTest.cpp:

Classes

class  MyDownloader
 
class  MyChecker
 
struct  TestDataForCheckArtifact
 
class  CheckArtifactTest
 
class  DownloadTest
 
struct  UrlData
 
class  UrlParserTest
 

Functions

static string replace_string (const string &source, const string &what, const string &replacement)
 
 TEST_P (CheckArtifactTest, parametrizedTest)
 
 INSTANTIATE_TEST_CASE_P (ArtifactCheckTest, CheckArtifactTest, ValuesIn< vector< TestDataForCheckArtifact >>({{"Happy case", valid_request, true, valid_response, false, true, "Content-Type: application/json"}, {"HTTP GET failed", valid_request, false, "", true, false, "Content-Type: application/json"}, {"GET failed w/response", valid_request, false, valid_response, true, false, "Content-Type: application/json"}, {"Empty response", valid_request, true, "", true, false, "Content-Type: application/json"}, {"Invalid JSON", valid_request, true, "Golden Fleece", true, false, "Content-Type: application/json"}, {"Valid JSON, no data", valid_request, true, "{\MZN\1917}", true, false, "Content-Type: application/json"}, {"Valid JSON, bad data", valid_request, true, negative_expiry, true, false, "Content-Type: application/json"}, {"String instead of int", valid_request, true, int_as_string, true, false, "Content-Type: application/json"}, {"Insecure response OK", valid_request, true, insecure_response, false, true, "Content-Type: application/json"}, {"Multi-part happy case", valid_request, true, valid_multipart_full_response, false, false, "Content-Type: multipart/mixed; boundary=--90378d5d-5961-4c14-9105-d968ad9f2ba8\"} }), PrintDescription())
 
 TEST_F (DownloadTest, fromPublishToDownloadTest)
 
 TEST_F (DownloadTest, downloadWithThrottlingTest)
 
 TEST_F (DownloadTest, downloadFailureDoesntRetryForeverTest)
 
 TEST_F (DownloadTest, downloadCanRecoverTest)
 
 TEST_F (DownloadTest, downloadRetriesWithThrottlingTest)
 
 TEST_F (DownloadTest, BackOffTimeLimitsTest)
 
 TEST_F (DownloadTest, BackOffIncrements)
 
 TEST_P (UrlParserTest, urlParser)
 
 INSTANTIATE_TEST_CASE_P (PossibleTests, UrlParserTest, ValuesIn< vector< UrlData >>({{"https://device-artifacts-v2.s3.amazonaws.com/file.tar.gz?X-Amz-Algorithm=AW", "file.tar.gz"}, {"http://device-artifacts-v2.s3.amazonaws.com/file.tar.gz", "file.tar.gz"}, {"https://device-artifacts-v2.s3.amazonaws.com/file.tar.gz?X-Amz-Algorithm=AW", "file.tar.gz"}, {"https://s3.amazonaws.com/f", "f"}, {"https://s3.amazonaws.com/f?", "f"}, {"https://s3.amazonaws.com/?hi/file.tar.gz?bye", "file.tar.gz"}, {"https://amazonaws.com/file.tar.gz?X-Amz-Algorithm=AW", "file.tar.gz"}, {"https://azamonaws.com/file.tar.gz?X-Amz-Algorithm=AW", default_value}, {"https://s3.amazon.com/file.tar.gz?X-Amz-Algorithm=AW", default_value}, {"https://s3.amazonaws.com/?X-Amz", default_value}, }))
 

Variables

static milliseconds INTIIAL_BACKOFF_VALUE = milliseconds(100)
 
static milliseconds BASE_BACKOFF_VALUE = milliseconds(10)
 
static milliseconds MAX_BACKOFF_VALUE = milliseconds(50)
 
string valid_request
 
string valid_response
 
auto insecure_response = replace_string(valid_response, "https://", "http://")
 
auto negative_expiry = replace_string(valid_response, "\"urlExpiryEpoch\": 1537400172798,", "\"urlExpiryEpoch\": -12,")
 
auto int_as_string = replace_string(valid_response, "4485147", "\"4485147\"")
 
string valid_multipart_full_response
 
string default_value = "default_value"
 

Function Documentation

◆ INSTANTIATE_TEST_CASE_P() [1/2]

INSTANTIATE_TEST_CASE_P ( ArtifactCheckTest  ,
CheckArtifactTest  ,
ValuesIn< vector< TestDataForCheckArtifact >>  {{"Happy case", valid_request, true, valid_response, false, true, "Content-Type: application/json"}, {"HTTP GET failed", valid_request, false, "", true, false, "Content-Type: application/json"}, {"GET failed w/response", valid_request, false, valid_response, true, false, "Content-Type: application/json"}, {"Empty response", valid_request, true, "", true, false, "Content-Type: application/json"}, {"Invalid JSON", valid_request, true, "Golden Fleece", true, false, "Content-Type: application/json"}, {"Valid JSON, no data", valid_request, true, "{\ZN\917}", true, false, "Content-Type: application/json"}, {"Valid JSON, bad data", valid_request, true, negative_expiry, true, false, "Content-Type: application/json"}, {"String instead of int", valid_request, true, int_as_string, true, false, "Content-Type: application/json"}, {"Insecure response OK", valid_request, true, insecure_response, false, true, "Content-Type: application/json"}, {"Multi-part happy case", valid_request, true, valid_multipart_full_response, false, false, "Content-Type: multipart/mixed; boundary=--90378d5d-5961-4c14-9105-d968ad9f2ba8\} },
PrintDescription()   
)

◆ INSTANTIATE_TEST_CASE_P() [2/2]

INSTANTIATE_TEST_CASE_P ( PossibleTests  ,
UrlParserTest  ,
ValuesIn< vector< UrlData >>  {{"https://device-artifacts-v2.s3.amazonaws.com/file.tar.gz?X-Amz-Algorithm=AW", "file.tar.gz"}, {"http://device-artifacts-v2.s3.amazonaws.com/file.tar.gz", "file.tar.gz"}, {"https://device-artifacts-v2.s3.amazonaws.com/file.tar.gz?X-Amz-Algorithm=AW", "file.tar.gz"}, {"https://s3.amazonaws.com/f", "f"}, {"https://s3.amazonaws.com/f?", "f"}, {"https://s3.amazonaws.com/?hi/file.tar.gz?bye", "file.tar.gz"}, {"https://amazonaws.com/file.tar.gz?X-Amz-Algorithm=AW", "file.tar.gz"}, {"https://azamonaws.com/file.tar.gz?X-Amz-Algorithm=AW", default_value}, {"https://s3.amazon.com/file.tar.gz?X-Amz-Algorithm=AW", default_value}, {"https://s3.amazonaws.com/?X-Amz", default_value}, } 
)

◆ replace_string()

static string replace_string ( const string &  source,
const string &  what,
const string &  replacement 
)
static

◆ TEST_F() [1/7]

TEST_F ( DownloadTest  ,
fromPublishToDownloadTest   
)

◆ TEST_F() [2/7]

TEST_F ( DownloadTest  ,
downloadWithThrottlingTest   
)

◆ TEST_F() [3/7]

TEST_F ( DownloadTest  ,
downloadFailureDoesntRetryForeverTest   
)

◆ TEST_F() [4/7]

TEST_F ( DownloadTest  ,
downloadCanRecoverTest   
)

◆ TEST_F() [5/7]

TEST_F ( DownloadTest  ,
downloadRetriesWithThrottlingTest   
)

◆ TEST_F() [6/7]

TEST_F ( DownloadTest  ,
BackOffTimeLimitsTest   
)

◆ TEST_F() [7/7]

TEST_F ( DownloadTest  ,
BackOffIncrements   
)

◆ TEST_P() [1/2]

TEST_P ( CheckArtifactTest  ,
parametrizedTest   
)

◆ TEST_P() [2/2]

TEST_P ( UrlParserTest  ,
urlParser   
)

Variable Documentation

◆ BASE_BACKOFF_VALUE

milliseconds BASE_BACKOFF_VALUE = milliseconds(10)
static

◆ default_value

string default_value = "default_value"

◆ insecure_response

auto insecure_response = replace_string(valid_response, "https://", "http://")

◆ int_as_string

auto int_as_string = replace_string(valid_response, "4485147", "\"4485147\"")

◆ INTIIAL_BACKOFF_VALUE

milliseconds INTIIAL_BACKOFF_VALUE = milliseconds(100)
static

◆ MAX_BACKOFF_VALUE

milliseconds MAX_BACKOFF_VALUE = milliseconds(50)
static

◆ negative_expiry

auto negative_expiry = replace_string(valid_response, "\"urlExpiryEpoch\": 1537400172798,", "\"urlExpiryEpoch\": -12,")

◆ valid_multipart_full_response

string valid_multipart_full_response
Initial value:
= R"(--90378d5d-5961-4c14-9105-d968ad9f2ba8\r
Content-Type: application/json
{"artifactType": "wakeword","artifactKey": "alexa","artifactTimeToLive": 1570483487469,"artifactIdentifier": "56e662bbcaafd80f6eadcbe1bb6d837a","artifactSize": 55, "checksum": {"md5": "56e662bbcaafd80f6eadcbe1bb6d837a"}}
--90378d5d-5961-4c14-9105-d968ad9f2ba8\r
Content-Type: application/octet-stream
000 blobbyblobbyblobbyblobby
001 blobbyblobbyblobbyblobby
002 blobbyblobbyblobbyblobby
003 blobbyblobbyblobbyblobby
004 blobbyblobbyblobbyblobby
005 blobbyblobbyblobbyblobby
006 blobbyblobbyblobbyblobby
007 blobbyblobbyblobbyblobby
008 blobbyblobbyblobbyblobby
009 blobbyblobbyblobbyblobby
010 blobbyblobbyblobbyblobby
011 blobbyblobbyblobbyblobby
012 blobbyblobbyblobbyblobby
)"

◆ valid_request

string valid_request
Initial value:
=
R"({"artifactType":"wakeword","artifactKey":"alexa","filters":{"locale":["en-US"],"modelClass":["B"]}})"

◆ valid_response

string valid_response
Initial value:
= R"(
{
"urlExpiryEpoch": 1537400172798,
"artifactType": "wakeword",
"artifactSize": 4485147,
"artifactKey": "alexa",
"artifactTimeToLive": 1537400172798,
"downloadUrl": "https://device-artifacts-v2.s3.amazonaws.com/wakeword-alexa-8aac547c6d1c48cc16dc317900d3ba8e.tar.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20180919T223612Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=AKIAJTPKJI7A3WTMPCQQ%2F20180919%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=87160eda6c8325e9ce61120974cdf2f81c4b8a3d47c1192f6cf4b7500ed17165",
"artifactIdentifier": "8aac547c6d1c48cc16dc317900d3ba8e"
})"

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0