AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#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"
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" |
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 | ( | 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}, } | ||
) |
|
static |
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 | ( | CheckArtifactTest | , |
parametrizedTest | |||
) |
TEST_P | ( | UrlParserTest | , |
urlParser | |||
) |
|
static |
string default_value = "default_value" |
auto insecure_response = replace_string(valid_response, "https://", "http://") |
auto int_as_string = replace_string(valid_response, "4485147", "\"4485147\"") |
|
static |
|
static |
auto negative_expiry = replace_string(valid_response, "\"urlExpiryEpoch\": 1537400172798,", "\"urlExpiryEpoch\": -12,") |
string valid_multipart_full_response |
string valid_request |
string valid_response |
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0