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

Classes

class  LWAAuthorizationAdapterTest
 
class  LWAAuthorizationStorageTest
 
class  LWAAuthStorageMigrationTest
 
class  MockAuthManager
 A mock AuthorizationManager. More...
 
class  MockCBLObserver
 A mock observer. More...
 
class  StubStorage
 

Functions

 TEST_F (LWAAuthorizationAdapterTest, test_create_NullParams_Nullptr)
 Test create with null ptr. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_id_DefaultValue)
 Check the default value for the adapter id both directly and via getAuthorizationInterface. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_getAuthTokenNoAuth_Fails)
 Check that no token is returned when not authorized. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_id_CustomValue)
 Check the custom value for the adapter id both directly and via getAuthorizationInterface. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_authorize_NoAuthMgr_Fails)
 Check that authorizing without an AuthManager fails. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_multipleCBLAuthorization_Fails)
 Check that multiple authorization requests fail. Only one reportStateChange call for each state is expected. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_cblCodePairRetry_Succeeds)
 Check that the retry logic for CBL code pair requests is successful. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_cblTokenExchangeRetry_Succeeds)
 Check that the retry logic for CBL token exchange requests is successful. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_authFailure_TriggersRetry)
 Check that on auth failure, a retry is triggered. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_getState_Succeeds)
 Check that getState returns the correct state. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_reset_Succeeds)
 Check that reset operations are successful. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_refreshing_succeeds)
 Check that the LWA token refreshing logic is successful. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_reset_CodePair)
 Test resetting while waiting for code pair requests. More...
 
 TEST_F (LWAAuthorizationAdapterTest, test_reset_TokenExchange)
 Test resetting while waiting for token exchange requests. More...
 
 INSTANTIATE_TEST_CASE_P (Parameterized, LWAAuthorizationAdapterTest, ::testing::Values(AUTHORIZE_USING_CBL, AUTHORIZE_USING_CBL_WITH_CUSTOMER_PROFILE))
 Parameterized Tests Exercising both authorizeUsingCBL and authorizeUsingCBLWithCustomerProfile. More...
 
 TEST_P (LWAAuthorizationAdapterTest, test_cblAuthorize_Succeeds)
 Test that the happy case succeeds. More...
 
 TEST_P (LWAAuthorizationAdapterTest, test_cblAuthorize_CorrectScopes)
 Check that authorizeUsingCBL<WithCustomerProfile> is requesting with the correct scopes. More...
 
 TEST_F (LWAAuthorizationStorageTest, test_createFromEmptyStorage)
 
 TEST_F (LWAAuthorizationStorageTest, test_createFromNonEmptyStorage)
 
 TEST_F (LWAAuthorizationStorageTest, test_createFromEmptyDatabase)
 
 TEST_F (LWAAuthorizationStorageTest, test_createsTableAfterPutCloseAndReopen)
 
 TEST_F (LWAAuthStorageMigrationTest, test_migrateEmptyDatabase)
 Tests with creating a string key - string value table. More...
 
 TEST_F (LWAAuthStorageMigrationTest, test_migrateRefreshToken)
 
 TEST_F (LWAAuthStorageMigrationTest, test_migrateUserId)
 
 TEST_F (LWAAuthStorageMigrationTest, test_verifyMigrationForSameDatabase)
 

Variables

static const std::string USER_ID = "test-user-id"
 An example user id that would be returned by the Customer Profile API. More...
 
static const std::string NAME = "Test User"
 An example name that would be returned by the Customer Profile API. More...
 
static const std::string EMAIL = "test@user.com"
 An example email that would be returned by the Customer Profile API. More...
 
static const std::string VERIFICATION_URI = "https://amazon.com/us/code"
 The Veritifcation URI. More...
 
static const std::string USER_CODE = "ABCDE"
 An example CBL code to be returned from CBL auth. More...
 
static const std::string DEVICE_CODE = "deviceCode"
 An example device code to be returned from CBL auth. More...
 
static const std::string ADAPTER_ID = "test-adapter-id"
 A test adapter id. More...
 
const std::string DEFAULT_ADAPTER_ID = "lwa-adapter"
 Default adapter id. More...
 
std::chrono::seconds TIMEOUT {2}
 Timeout for test cases that require synchronization. More...
 
std::chrono::seconds LONG_TIMEOUT {20}
 Long timeout for cases involving waiting for retries. More...
 
static const std::string CONFIG_ROOT_NODE = "lwaAuthorization"
 The config node for the LWAAuthorizationAdapter. More...
 
static const std::string AUTHORIZE_USING_CBL = "authorizeUsingCBL"
 The method name for authorizeUsingCBL. More...
 
static const std::string AUTHORIZE_USING_CBL_WITH_CUSTOMER_PROFILE = "authorizeUsingCBLWithCustomerProfile"
 The method name for authorizeUsingCBLWithCustomerProfile. More...
 
const std::string EXPIRATION_S = "3600"
 Example responses from LWA. More...
 
const std::string INTERVAL_S = "3600"
 
const std::string ACCESS_TOKEN = "myaccesstoken"
 
const std::string REFRESH_TOKEN = "myrefreshtoken"
 
const std::string TOKEN_TYPE = "bearer"
 
const std::string EXPIRATION = "3600"
 
static const std::string CONFIG_JSON
 The Config JSON. More...
 
static const HTTPResponse CODE_PAIR_RESPONSE
 A default successful code pair response. More...
 
static const HTTPResponse TOKEN_EXCHANGE_RESPONSE
 A default successful token exchange response. More...
 
static const HTTPResponse CUSTOMER_PROFILE_SHORT_RESPONSE
 A defauilt successful customer profile response containing only the user id. More...
 
static const HTTPResponse CUSTOMER_PROFILE_RESPONSE
 A defauilt successful customer profile response. More...
 
static const std::string COMPONENT_NAME = "config"
 Component name for the misc DB tables. More...
 
static const std::string TABLE_NAME = "LWAAuthorizationStorage"
 Table name for the misc DB tables. More...
 
static const std::string REFRESH_TOKEN_VALUE = "refreshTokenValue"
 Test value for refresh token. More...
 
static const std::string USER_ID_VALUE = "userIdValue"
 Test value for user id. More...
 
static const std::string MISC_DB_CONFIG_JSON
 JSON text for miscDB config. More...
 
static const std::string TAG = "LWAAuthStorageMigrationTest"
 Logging tag. More...
 
static const std::string COMPONENT_NAME = "config"
 Component name for the misc DB tables. More...
 
static const std::string TABLE_NAME = "LWAAuthorizationStorage"
 Table name for the misc DB tables. More...
 
static const std::string PROPERTIES_URI = COMPONENT_NAME + "/" + TABLE_NAME
 Full table name. More...
 
static const std::string TABLE_NAME_REFRESH_TOKEN = "refreshToken"
 Full table name for legacy refresh token. More...
 
static const std::string TABLE_NAME_USER_ID = "userId"
 Full table name for legacy user id. More...
 

Function Documentation

◆ INSTANTIATE_TEST_CASE_P()

alexaClientSDK::acsdkAuthorization::lwa::test::INSTANTIATE_TEST_CASE_P ( Parameterized  ,
LWAAuthorizationAdapterTest  ,
::testing::Values(AUTHORIZE_USING_CBL, AUTHORIZE_USING_CBL_WITH_CUSTOMER_PROFILE  
)

Parameterized Tests Exercising both authorizeUsingCBL and authorizeUsingCBLWithCustomerProfile.

◆ TEST_F() [1/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationStorageTest  ,
test_createFromEmptyStorage   
)

◆ TEST_F() [2/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationStorageTest  ,
test_createFromNonEmptyStorage   
)

◆ TEST_F() [3/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthStorageMigrationTest  ,
test_migrateEmptyDatabase   
)

Tests with creating a string key - string value table.

◆ TEST_F() [4/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthStorageMigrationTest  ,
test_migrateRefreshToken   
)

◆ TEST_F() [5/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationStorageTest  ,
test_createFromEmptyDatabase   
)

◆ TEST_F() [6/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthStorageMigrationTest  ,
test_migrateUserId   
)

◆ TEST_F() [7/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationStorageTest  ,
test_createsTableAfterPutCloseAndReopen   
)

◆ TEST_F() [8/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthStorageMigrationTest  ,
test_verifyMigrationForSameDatabase   
)

◆ TEST_F() [9/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_create_NullParams_Nullptr   
)

Test create with null ptr.

◆ TEST_F() [10/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_id_DefaultValue   
)

Check the default value for the adapter id both directly and via getAuthorizationInterface.

◆ TEST_F() [11/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_getAuthTokenNoAuth_Fails   
)

Check that no token is returned when not authorized.

◆ TEST_F() [12/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_id_CustomValue   
)

Check the custom value for the adapter id both directly and via getAuthorizationInterface.

◆ TEST_F() [13/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_authorize_NoAuthMgr_Fails   
)

Check that authorizing without an AuthManager fails.

◆ TEST_F() [14/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_multipleCBLAuthorization_Fails   
)

Check that multiple authorization requests fail. Only one reportStateChange call for each state is expected.

◆ TEST_F() [15/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_cblCodePairRetry_Succeeds   
)

Check that the retry logic for CBL code pair requests is successful.

◆ TEST_F() [16/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_cblTokenExchangeRetry_Succeeds   
)

Check that the retry logic for CBL token exchange requests is successful.

◆ TEST_F() [17/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_authFailure_TriggersRetry   
)

Check that on auth failure, a retry is triggered.

◆ TEST_F() [18/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_getState_Succeeds   
)

Check that getState returns the correct state.

◆ TEST_F() [19/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_reset_Succeeds   
)

Check that reset operations are successful.

◆ TEST_F() [20/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_refreshing_succeeds   
)

Check that the LWA token refreshing logic is successful.

◆ TEST_F() [21/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_reset_CodePair   
)

Test resetting while waiting for code pair requests.

◆ TEST_F() [22/22]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_F ( LWAAuthorizationAdapterTest  ,
test_reset_TokenExchange   
)

Test resetting while waiting for token exchange requests.

◆ TEST_P() [1/2]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_P ( LWAAuthorizationAdapterTest  ,
test_cblAuthorize_Succeeds   
)

Test that the happy case succeeds.

◆ TEST_P() [2/2]

alexaClientSDK::acsdkAuthorization::lwa::test::TEST_P ( LWAAuthorizationAdapterTest  ,
test_cblAuthorize_CorrectScopes   
)

Check that authorizeUsingCBL<WithCustomerProfile> is requesting with the correct scopes.

Variable Documentation

◆ ACCESS_TOKEN

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::ACCESS_TOKEN = "myaccesstoken"

◆ ADAPTER_ID

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::ADAPTER_ID = "test-adapter-id"
static

A test adapter id.

◆ AUTHORIZE_USING_CBL

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::AUTHORIZE_USING_CBL = "authorizeUsingCBL"
static

The method name for authorizeUsingCBL.

◆ AUTHORIZE_USING_CBL_WITH_CUSTOMER_PROFILE

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::AUTHORIZE_USING_CBL_WITH_CUSTOMER_PROFILE = "authorizeUsingCBLWithCustomerProfile"
static

The method name for authorizeUsingCBLWithCustomerProfile.

◆ CODE_PAIR_RESPONSE

const HTTPResponse alexaClientSDK::acsdkAuthorization::lwa::test::CODE_PAIR_RESPONSE
static
Initial value:
{
R"(
{
"user_code": ")" + USER_CODE + R"(",
"device_code": ")" + DEVICE_CODE + R"(",
"verification_uri": ")" + VERIFICATION_URI +
R"(",
"expires_in": )" + EXPIRATION_S + R"(,
"interval": )" + INTERVAL_S + R"(
})"}
static const std::string VERIFICATION_URI
The Veritifcation URI.
Definition: LWAAuthorizationAdapterTest.cpp:59
HTTP Success with response payload.
Definition: HttpResponseCodes.h:31
static const std::string USER_CODE
An example CBL code to be returned from CBL auth.
Definition: LWAAuthorizationAdapterTest.cpp:62
const std::string EXPIRATION_S
Example responses from LWA.
Definition: LWAAuthorizationAdapterTest.cpp:89
static const std::string DEVICE_CODE
An example device code to be returned from CBL auth.
Definition: LWAAuthorizationAdapterTest.cpp:65
const std::string INTERVAL_S
Definition: LWAAuthorizationAdapterTest.cpp:90

A default successful code pair response.

◆ COMPONENT_NAME [1/2]

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::COMPONENT_NAME = "config"
static

Component name for the misc DB tables.

◆ COMPONENT_NAME [2/2]

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::COMPONENT_NAME = "config"
static

Component name for the misc DB tables.

◆ CONFIG_JSON

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::CONFIG_JSON
static
Initial value:
= R"(
{
"deviceInfo" : {
"clientId":"MyClientId",
"productId":"MyProductId",
"deviceSerialNumber":"0",
"manufacturerName":"MyCompany",
"description":"MyCommpany"
},
")" + CONFIG_ROOT_NODE + R"(" : {}
}
)"
static const std::string CONFIG_ROOT_NODE
The config node for the LWAAuthorizationAdapter.
Definition: LWAAuthorizationAdapterTest.cpp:80

The Config JSON.

◆ CONFIG_ROOT_NODE

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::CONFIG_ROOT_NODE = "lwaAuthorization"
static

The config node for the LWAAuthorizationAdapter.

◆ CUSTOMER_PROFILE_RESPONSE

const HTTPResponse alexaClientSDK::acsdkAuthorization::lwa::test::CUSTOMER_PROFILE_RESPONSE
static
Initial value:
{
R"(
{
"user_id": ")" + USER_ID + R"(",
"name": ")" + NAME + R"(",
"email": ")" + EMAIL + R"("
})"}
static const std::string NAME
An example name that would be returned by the Customer Profile API.
Definition: LWAAuthorizationAdapterTest.cpp:53
static const std::string EMAIL
An example email that would be returned by the Customer Profile API.
Definition: LWAAuthorizationAdapterTest.cpp:56
HTTP Success with response payload.
Definition: HttpResponseCodes.h:31
static const std::string USER_ID
An example user id that would be returned by the Customer Profile API.
Definition: LWAAuthorizationAdapterTest.cpp:50

A defauilt successful customer profile response.

◆ CUSTOMER_PROFILE_SHORT_RESPONSE

const HTTPResponse alexaClientSDK::acsdkAuthorization::lwa::test::CUSTOMER_PROFILE_SHORT_RESPONSE
static
Initial value:
{
R"(
{
"user_id": ")" + USER_ID + R"("
})"}
HTTP Success with response payload.
Definition: HttpResponseCodes.h:31
static const std::string USER_ID
An example user id that would be returned by the Customer Profile API.
Definition: LWAAuthorizationAdapterTest.cpp:50

A defauilt successful customer profile response containing only the user id.

◆ DEFAULT_ADAPTER_ID

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::DEFAULT_ADAPTER_ID = "lwa-adapter"

Default adapter id.

◆ DEVICE_CODE

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::DEVICE_CODE = "deviceCode"
static

An example device code to be returned from CBL auth.

◆ EMAIL

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::EMAIL = "test@user.com"
static

An example email that would be returned by the Customer Profile API.

◆ EXPIRATION

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::EXPIRATION = "3600"

◆ EXPIRATION_S

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::EXPIRATION_S = "3600"

Example responses from LWA.

◆ INTERVAL_S

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::INTERVAL_S = "3600"

◆ LONG_TIMEOUT

std::chrono::seconds alexaClientSDK::acsdkAuthorization::lwa::test::LONG_TIMEOUT {20}

Long timeout for cases involving waiting for retries.

◆ MISC_DB_CONFIG_JSON

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::MISC_DB_CONFIG_JSON
static
Initial value:
= R"(
{
"lwaAuthorization": {
"databaseFilePath":"LWAAuthorizationStorageTest.db"
}
}
)"

JSON text for miscDB config.

◆ NAME

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::NAME = "Test User"
static

An example name that would be returned by the Customer Profile API.

◆ PROPERTIES_URI

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::PROPERTIES_URI = COMPONENT_NAME + "/" + TABLE_NAME
static

Full table name.

◆ REFRESH_TOKEN

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::REFRESH_TOKEN = "myrefreshtoken"

◆ REFRESH_TOKEN_VALUE

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::REFRESH_TOKEN_VALUE = "refreshTokenValue"
static

Test value for refresh token.

◆ TABLE_NAME [1/2]

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::TABLE_NAME = "LWAAuthorizationStorage"
static

Table name for the misc DB tables.

◆ TABLE_NAME [2/2]

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::TABLE_NAME = "LWAAuthorizationStorage"
static

Table name for the misc DB tables.

◆ TABLE_NAME_REFRESH_TOKEN

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::TABLE_NAME_REFRESH_TOKEN = "refreshToken"
static

Full table name for legacy refresh token.

◆ TABLE_NAME_USER_ID

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::TABLE_NAME_USER_ID = "userId"
static

Full table name for legacy user id.

◆ TAG

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::TAG = "LWAAuthStorageMigrationTest"
static

Logging tag.

◆ TIMEOUT

std::chrono::seconds alexaClientSDK::acsdkAuthorization::lwa::test::TIMEOUT {2}

Timeout for test cases that require synchronization.

◆ TOKEN_EXCHANGE_RESPONSE

const HTTPResponse alexaClientSDK::acsdkAuthorization::lwa::test::TOKEN_EXCHANGE_RESPONSE
static
Initial value:
{
R"(
{
"access_token": ")" + ACCESS_TOKEN + R"(",
"refresh_token": ")" + REFRESH_TOKEN + R"(",
"token_type": ")" + TOKEN_TYPE + R"(",
"expires_in": )" + EXPIRATION + R"(
})"}
const std::string EXPIRATION
Definition: LWAAuthorizationAdapterTest.cpp:94
const std::string TOKEN_TYPE
Definition: LWAAuthorizationAdapterTest.cpp:93
const std::string ACCESS_TOKEN
Definition: LWAAuthorizationAdapterTest.cpp:91
HTTP Success with response payload.
Definition: HttpResponseCodes.h:31
const std::string REFRESH_TOKEN
Definition: LWAAuthorizationAdapterTest.cpp:92

A default successful token exchange response.

◆ TOKEN_TYPE

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::TOKEN_TYPE = "bearer"

◆ USER_CODE

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::USER_CODE = "ABCDE"
static

An example CBL code to be returned from CBL auth.

◆ USER_ID

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::USER_ID = "test-user-id"
static

An example user id that would be returned by the Customer Profile API.

◆ USER_ID_VALUE

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::USER_ID_VALUE = "userIdValue"
static

Test value for user id.

◆ VERIFICATION_URI

const std::string alexaClientSDK::acsdkAuthorization::lwa::test::VERIFICATION_URI = "https://amazon.com/us/code"
static

The Veritifcation URI.

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