@@ -883,6 +883,7 @@ TEST_F(AuthorizationTest, validate_token_auth_cache_accepted) {
883883}
884884
885885TEST_F (AuthorizationTest, validate_token_auth_local_pre_authorize_disabled) {
886+ EXPECT_CALL (this ->connectivity_manager , is_websocket_connected ()).WillRepeatedly (Return (true ));
886887 // Enable auth cache.
887888 this ->set_auth_cache_enabled (this ->device_model , true );
888889 // Disable local auth list.
@@ -894,12 +895,9 @@ TEST_F(AuthorizationTest, validate_token_auth_local_pre_authorize_disabled) {
894895 // Disable post authorization of the auth cache
895896 this ->set_disable_post_authorize (this ->device_model , true );
896897
897- AuthorizationCacheEntry authorization_cache_entry =
898- create_authorization_cache_entry (AuthorizationStatusEnum::Accepted, true , false , false , 5000 );
899-
900- EXPECT_CALL (this ->database_handler_mock , authorization_cache_get_entry (_))
901- .WillOnce (Return (authorization_cache_entry));
902-
898+ EXPECT_CALL (mock_dispatcher, dispatch_call_async (_, _)).WillOnce (Return (std::async (std::launch::deferred, [this ]() {
899+ return create_example_authorize_response (std::nullopt , AuthorizationStatusEnum::Accepted);
900+ })));
903901 IdToken id_token;
904902 id_token.type = IdTokenEnumStringType::ISO14443;
905903 id_token.idToken = " test_token" ;
@@ -1902,3 +1900,62 @@ TEST_F(AuthorizationTest, cache_cleanup_handler_database_exception) {
19021900 this ->authorization ->trigger_authorization_cache_cleanup ();
19031901 this ->wait_for_calls (0 , 2 , 0 );
19041902}
1903+
1904+ TEST_F (AuthorizationTest, online_local_pre_authorize_local_list) {
1905+ ON_CALL (this ->connectivity_manager , is_websocket_connected ()).WillByDefault (Return (true ));
1906+
1907+ this ->set_auth_ctrlr_enabled (this ->device_model , true );
1908+ this ->set_local_auth_list_ctrlr_enabled (this ->device_model , true );
1909+ this ->set_auth_cache_enabled (this ->device_model , false );
1910+ this ->set_local_pre_authorize (this ->device_model , true );
1911+ this ->set_local_authorize_offline (this ->device_model , false );
1912+
1913+ IdTokenInfo id_token_info_result;
1914+ id_token_info_result.status = AuthorizationStatusEnum::Accepted;
1915+
1916+ EXPECT_CALL (this ->database_handler_mock , get_local_authorization_list_entry (_))
1917+ .WillRepeatedly (Return (id_token_info_result));
1918+
1919+ IdToken id_token;
1920+ id_token.type = IdTokenEnumStringType::ISO14443;
1921+ id_token.idToken = " test_token" ;
1922+
1923+ EXPECT_EQ (authorization->validate_token (id_token, std::nullopt , std::nullopt ).idTokenInfo .status ,
1924+ AuthorizationStatusEnum::Accepted);
1925+ }
1926+
1927+ TEST_F (AuthorizationTest, offline_local_pre_authorize_local_list) {
1928+ ON_CALL (this ->connectivity_manager , is_websocket_connected ()).WillByDefault (Return (false ));
1929+
1930+ this ->set_auth_ctrlr_enabled (this ->device_model , true );
1931+ this ->set_local_auth_list_ctrlr_enabled (this ->device_model , true );
1932+ this ->set_auth_cache_enabled (this ->device_model , true );
1933+ this ->set_local_pre_authorize (this ->device_model , true );
1934+ this ->set_local_authorize_offline (this ->device_model , false );
1935+ this ->set_offline_tx_for_unknown_id_enabled (this ->device_model , false );
1936+
1937+ IdToken id_token;
1938+ id_token.type = IdTokenEnumStringType::ISO14443;
1939+ id_token.idToken = " test_token" ;
1940+
1941+ EXPECT_EQ (authorization->validate_token (id_token, std::nullopt , std::nullopt ).idTokenInfo .status ,
1942+ AuthorizationStatusEnum::Unknown);
1943+ }
1944+
1945+ TEST_F (AuthorizationTest, offline_local_pre_authorize_cache) {
1946+ ON_CALL (this ->connectivity_manager , is_websocket_connected ()).WillByDefault (Return (false ));
1947+
1948+ this ->set_auth_ctrlr_enabled (this ->device_model , true );
1949+ this ->set_local_auth_list_ctrlr_enabled (this ->device_model , true );
1950+ this ->set_auth_cache_enabled (this ->device_model , true );
1951+ this ->set_local_pre_authorize (this ->device_model , true );
1952+ this ->set_local_authorize_offline (this ->device_model , false );
1953+ this ->set_offline_tx_for_unknown_id_enabled (this ->device_model , false );
1954+
1955+ IdToken id_token;
1956+ id_token.type = IdTokenEnumStringType::ISO14443;
1957+ id_token.idToken = " test_token" ;
1958+
1959+ EXPECT_EQ (authorization->validate_token (id_token, std::nullopt , std::nullopt ).idTokenInfo .status ,
1960+ AuthorizationStatusEnum::Unknown);
1961+ }
0 commit comments