AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Functions | Variables
alexaClientSDK::avsGatewayManager::test Namespace Reference

Classes

class  AuthRefreshedObserverTest
 
class  AVSGatewayManagerTest
 
struct  EventData
 
class  MockAuthDelegate
 
class  MockAVSGatewayManagerStorage
 
class  PostConnectVerifyGatewaySenderTest
 

Functions

 TEST_F (AuthRefreshedObserverTest, onAuthStatusChangeToRefreshed)
 
 TEST_F (AuthRefreshedObserverTest, onAuthStatusChangeToRefreshedExpired)
 
 TEST_F (AuthRefreshedObserverTest, onAuthStatusChangeToUnitialized)
 
 TEST_F (AuthRefreshedObserverTest, onAuthStatusChangeToUnrecoverable)
 
 TEST_F (AVSGatewayManagerTest, test_createAVSGatewayManagerWithInvalidParameters)
 
 TEST_F (AVSGatewayManagerTest, test_defaultAVSGatewayFromConfigFile)
 
 TEST_F (AVSGatewayManagerTest, test_defaultAVSGatewayFromConfigFileWithNoGateway)
 
 TEST_F (AVSGatewayManagerTest, test_defaultAVSGatewayFromConfigFileWithEmptyGateway)
 
 TEST_F (AVSGatewayManagerTest, test_avsGatewayFromStorage)
 
 TEST_F (AVSGatewayManagerTest, test_setAVSGatewayURLWithNewURL)
 
 TEST_F (AVSGatewayManagerTest, test_setAVSGatewayURLWithSameURL)
 
 TEST_F (AVSGatewayManagerTest, test_setAVSGatewayURLWithoutAssigner)
 
 TEST_F (AVSGatewayManagerTest, test_addNullObserver)
 
 TEST_F (AVSGatewayManagerTest, test_removeNullObserver)
 
 TEST_F (AVSGatewayManagerTest, test_removeAddedObserver)
 
 TEST_F (AVSGatewayManagerTest, test_removeObserverNotAddedPreviously)
 
 TEST_F (AVSGatewayManagerTest, test_clearData)
 
 TEST_F (AVSGatewayManagerTest, test_createPostConnectOperationMultipleTimesWhenDBIsEmpty)
 
 TEST_F (AVSGatewayManagerTest, test_createPostConnectOperationRetunrsNullIfDBContainsVerifiedGateway)
 
 TEST_F (AVSGatewayManagerTest, test_createPostConnectOperationSequenceAfterSetGatewayURL)
 
 TEST_F (AVSGatewayManagerTest, test_createPostConnectOperationHasAuthObserver)
 
bool parseEventJson (const std::string &eventJson, EventData *eventData)
 
bool validateEvent (const std::string &eventJson)
 
 TEST_F (PostConnectVerifyGatewaySenderTest, test_creaetWithEmptyCallbackMethod)
 
 TEST_F (PostConnectVerifyGatewaySenderTest, test_performGatewayWhen204IsReceived)
 
 TEST_F (PostConnectVerifyGatewaySenderTest, test_performGatewayWhen200IsReceived)
 
 TEST_F (PostConnectVerifyGatewaySenderTest, test_performGatewayWhen400IsReceived)
 
 TEST_F (PostConnectVerifyGatewaySenderTest, test_performGatewayRetriesWhen503IsReceived)
 
 TEST_F (PostConnectVerifyGatewaySenderTest, test_performGatewayWakesUpAndWaitingToRetry)
 

Variables

static const std::string TEST_AVS_GATEWAY = "www.test-avs-gateway.com"
 Test AVS Gateway. More...
 
static const std::string DEFAULT_AVS_GATEWAY = "https://alexa.na.gateway.devices.a2z.com"
 Default AVS Gateway. More...
 
static const std::string STORED_AVS_GATEWAY = "www.avs-gatewa-from-storage.com"
 Stored AVS Gateway. More...
 
static const std::string AVS_GATEWAY_MANAGER_JSON
 
static const std::string AVS_GATEWAY_MANAGER_JSON_NO_GATEWAY
 
static const std::string AVS_GATEWAY_MANAGER_JSON_EMPTY_GATEWAY
 
static const std::string EXPECTED_NAMESPACE = "Alexa.ApiGateway"
 String indicating the VerifyGateway event's expected namespace. More...
 
static const std::string EXPECTED_NAME = "VerifyGateway"
 String indicating the VerifyGateway event's expected name. More...
 
static const std::string EXPECTED_PAYLOAD = "{}"
 String indicating the VerifyGateway event's expected payload. More...
 
static const int TEST_RETRY_COUNT = 3
 Number of retries used in tests. More...
 

Function Documentation

◆ parseEventJson()

bool alexaClientSDK::avsGatewayManager::test::parseEventJson ( const std::string &  eventJson,
EventData eventData 
)

◆ TEST_F() [1/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AuthRefreshedObserverTest  ,
onAuthStatusChangeToRefreshed   
)

◆ TEST_F() [2/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AuthRefreshedObserverTest  ,
onAuthStatusChangeToRefreshedExpired   
)

◆ TEST_F() [3/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AuthRefreshedObserverTest  ,
onAuthStatusChangeToUnitialized   
)

◆ TEST_F() [4/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AuthRefreshedObserverTest  ,
onAuthStatusChangeToUnrecoverable   
)

◆ TEST_F() [5/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( PostConnectVerifyGatewaySenderTest  ,
test_creaetWithEmptyCallbackMethod   
)

Test if the create method fails

◆ TEST_F() [6/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( PostConnectVerifyGatewaySenderTest  ,
test_performGatewayWhen204IsReceived   
)

Test happy path where performGateway returns true when VerifyGateway event is sent and 204 response is received.

◆ TEST_F() [7/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_createAVSGatewayManagerWithInvalidParameters   
)

◆ TEST_F() [8/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_defaultAVSGatewayFromConfigFile   
)

Test if a call to setAVSGatewayAssigner uses the gateway URL from the configuration file.

◆ TEST_F() [9/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( PostConnectVerifyGatewaySenderTest  ,
test_performGatewayWhen200IsReceived   
)

Test if performGateway returns false when VerifyGateway event is sent and 200 response is received.

◆ TEST_F() [10/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_defaultAVSGatewayFromConfigFileWithNoGateway   
)

Test if a call to setAVSGatewayAssigner uses the default gateway URL if configuration is not specified.

◆ TEST_F() [11/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( PostConnectVerifyGatewaySenderTest  ,
test_performGatewayWhen400IsReceived   
)

Test if performGateway returns false when VerifyGateway event is sent and 400 response is received.

◆ TEST_F() [12/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_defaultAVSGatewayFromConfigFileWithEmptyGateway   
)

Test if a call to setAVSGatewayAssigner uses the default gateway URL if avsGateway in configuration is empty.

◆ TEST_F() [13/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_avsGatewayFromStorage   
)

Test if a call to setAVSGatewayAssigner uses the gateway URL from storage. Also, test if the createPostConnectOperation() returns nullptr if the gateway has already been verified.

◆ TEST_F() [14/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( PostConnectVerifyGatewaySenderTest  ,
test_performGatewayRetriesWhen503IsReceived   
)

Test if performGateway retries sending VerifyGateway event when a 5xx response is received.

◆ TEST_F() [15/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_setAVSGatewayURLWithNewURL   
)

Test if a call to setGatewayURL() with a new URL calls

  • calls the setAVSGateway() method on AVSGatewayAssigner
  • calls the storeState() method on AVSGatewayManagerStorage
  • calls the onGatewayChanged() method on AVSGatewayObserver.

◆ TEST_F() [16/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( PostConnectVerifyGatewaySenderTest  ,
test_performGatewayWakesUpAndWaitingToRetry   
)

Test if performOperation wakes up from wait when it receives a wake up call while waiting to retry

◆ TEST_F() [17/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_setAVSGatewayURLWithSameURL   
)

Test if a call to setGatewayURL with the same URL does not trigger calls to AVSGatewayAssigner, AVSGatewayObserver and AVSGatewayManagerStorage.

◆ TEST_F() [18/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_setAVSGatewayURLWithoutAssigner   
)

◆ TEST_F() [19/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_addNullObserver   
)

Test if AVSGatewayManager gracefully handles adding a nullObserver.

◆ TEST_F() [20/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_removeNullObserver   
)

Test if AVSGatewayManager gracefully handles removing a nullObserver.

◆ TEST_F() [21/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_removeAddedObserver   
)

Test removing a previously added observer.

◆ TEST_F() [22/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_removeObserverNotAddedPreviously   
)

Test removing an observer that is not previously added is handled gracefully.

◆ TEST_F() [23/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_clearData   
)

Test if a call to clearData() invokes call to clear() on the storage.

◆ TEST_F() [24/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_createPostConnectOperationMultipleTimesWhenDBIsEmpty   
)

Test if a call to createPostConnectOperation() does the following: 1) Return a valid PostConnectVerifyGatewaySender when the database is empty. 2) Return nullptr on a subsequent call to createPostConnectOperation() if the gateway has been verified.

Note
This test simulates a fresh device connecting for the first time followed by a successful gateway verification after which a reconnection happens.

First call to createPostConnectOperation() when database is empty.

Expect state to be stored after a successful onGatewayVerified call.

Callback to indicate if the postConnectOperation successfully finished gateway verification.

Subsequent call to createPostConnectOperation() when gateway is verified.

◆ TEST_F() [25/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_createPostConnectOperationRetunrsNullIfDBContainsVerifiedGateway   
)

Test if a call to createPostConnectOperation() does the following: 1) Return a valid PostConnectVerifyGatewaySender when the database has gateway in unverified state. 2) Return nullptr on a subsequent call to createPostConnectOperation() if the gateway has been verified.

Note
This test simulates first connection followed by a reconnection when the database contains a gateway that has not been verified yet.

First call to createPostConnectOperation() when database has unverified gateway.

Expect state to be stored after a successful onGatewayVerified call.

Callback to indicate if the postConnectOperation successfully finished gateway verification.

Subsequent call to createPostConnectOperation() when gateway is verified.

◆ TEST_F() [26/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_createPostConnectOperationSequenceAfterSetGatewayURL   
)

Test if a call to createPostConnectOperation() does the following: 1) Return null if the database contains a verified gateway. 2) Returns a valid PostConnectVerifyGatewaySender after setGatewayURL is called with a different gateway. 3) Return null on a subsequent call to createPostConnectOperation().

Note
This test simulates a device starting up with verified gateway. Then a setGateway directive is received with a different gateway and after successful verification of the new gateway, a reconnection happens.

First call to createPostConnectOperation() when database has unverified gateway.

Expect state to be stored before verification.

Second call to createPostConnectOperation() creates a valid PostConnectVerifyGatewaySender.

Expect state to be stored after verification.

Callback to indicate if the postConnectOperation successfully finished gateway verification.

Subsequent call to createPostConnectOperation() when gateway is verified.

◆ TEST_F() [27/27]

alexaClientSDK::avsGatewayManager::test::TEST_F ( AVSGatewayManagerTest  ,
test_createPostConnectOperationHasAuthObserver   
)

Test if a call to createPostConnectOperation() adds an AuthRefreshedObserver to the AuthDelegate

First call to createPostConnectOperation() when database is empty.

◆ validateEvent()

bool alexaClientSDK::avsGatewayManager::test::validateEvent ( const std::string &  eventJson)

Variable Documentation

◆ AVS_GATEWAY_MANAGER_JSON

const std::string alexaClientSDK::avsGatewayManager::test::AVS_GATEWAY_MANAGER_JSON
static
Initial value:
= R"(
{
"avsGatewayManager" : {
"avsGateway":")" + TEST_AVS_GATEWAY + R"("
}
}
)"
static const std::string TEST_AVS_GATEWAY
Test AVS Gateway.
Definition: AVSGatewayManagerTest.cpp:37

◆ AVS_GATEWAY_MANAGER_JSON_EMPTY_GATEWAY

const std::string alexaClientSDK::avsGatewayManager::test::AVS_GATEWAY_MANAGER_JSON_EMPTY_GATEWAY
static
Initial value:
= R"(
{
"avsGatewayManager" : {
"avsGateway":""
}
}
)"

◆ AVS_GATEWAY_MANAGER_JSON_NO_GATEWAY

const std::string alexaClientSDK::avsGatewayManager::test::AVS_GATEWAY_MANAGER_JSON_NO_GATEWAY
static
Initial value:
= R"(
{
"avsGatewayManager" : {
}
}
)"

◆ DEFAULT_AVS_GATEWAY

const std::string alexaClientSDK::avsGatewayManager::test::DEFAULT_AVS_GATEWAY = "https://alexa.na.gateway.devices.a2z.com"
static

Default AVS Gateway.

◆ EXPECTED_NAME

const std::string alexaClientSDK::avsGatewayManager::test::EXPECTED_NAME = "VerifyGateway"
static

String indicating the VerifyGateway event's expected name.

◆ EXPECTED_NAMESPACE

const std::string alexaClientSDK::avsGatewayManager::test::EXPECTED_NAMESPACE = "Alexa.ApiGateway"
static

String indicating the VerifyGateway event's expected namespace.

◆ EXPECTED_PAYLOAD

const std::string alexaClientSDK::avsGatewayManager::test::EXPECTED_PAYLOAD = "{}"
static

String indicating the VerifyGateway event's expected payload.

◆ STORED_AVS_GATEWAY

const std::string alexaClientSDK::avsGatewayManager::test::STORED_AVS_GATEWAY = "www.avs-gatewa-from-storage.com"
static

Stored AVS Gateway.

◆ TEST_AVS_GATEWAY

const std::string alexaClientSDK::avsGatewayManager::test::TEST_AVS_GATEWAY = "www.test-avs-gateway.com"
static

Test AVS Gateway.

◆ TEST_RETRY_COUNT

const int alexaClientSDK::avsGatewayManager::test::TEST_RETRY_COUNT = 3
static

Number of retries used in tests.

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