Merge pull request #8229 from mirelachirica/fix_network_and_util_ut

Fix network and util ut
pull/8248/head
Cruz Monrreal 2018-09-25 10:35:36 -05:00 committed by GitHub
commit 3bec1b75c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 7 deletions

View File

@ -227,9 +227,8 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_activate_context)
ATHandler_stub::resp_stop_success_count = 2;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::bool_value = false;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == cn.activate_context());
EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == my_cn.activate_context());
// get_context return true and new context created, also do_user_authentication called with success.
// Now there is stack.

View File

@ -126,14 +126,14 @@ TEST_F(Testutil, separate_ip_addresses)
char ip[64] = {0};
char subnet[64] = {0};
strncpy(s, "32.1.20.187.1.112.139.245.251.136.232.110.123.51.230.138.0.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15", 94);
strncpy(s, "32.1.20.187.1.112.139.245.251.136.232.110.123.51.230.138.0.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15\0", 95);
separate_ip_addresses(NULL, ip, sizeof(ip), subnet, sizeof(subnet));
separate_ip_addresses(s, ip, sizeof(ip), subnet, sizeof(subnet));
EXPECT_STREQ("2001:14BB:170:8BF5:FB88:E86E:7B33:E68A", ip);
EXPECT_STREQ("001:203:405:607:809:A0B:C0D:E0F", subnet);
strncpy(s, "32:1:20:187:1:112:139:245:251:136:232:110:123:51:230:138 0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15", 94);
strncpy(s, "32:1:20:187:1:112:139:245:251:136:232:110:123:51:230:138 0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15\0", 95);
separate_ip_addresses(s, ip, sizeof(ip), subnet, sizeof(subnet));
EXPECT_STREQ("32:1:20:187:1:112:139:245:251:136:232:110:123:51:230:138", ip);
EXPECT_STREQ("0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15", subnet);

View File

@ -150,6 +150,9 @@ public:
op_status = Unknown;
op_rat = RAT_UNKNOWN;
next = NULL;
op_long[0] = NULL;
op_short[0] = NULL;
op_num[0] = NULL;
}
};

View File

@ -316,9 +316,10 @@ nsapi_error_t AT_CellularNetwork::activate_context()
if (!_is_context_active) {
// authenticate before activating or modifying context
if (do_user_authentication() != NSAPI_ERROR_OK) {
nsapi_error_t err = do_user_authentication();
if (err != NSAPI_ERROR_OK) {
tr_error("Cellular authentication failed!");
return _at.unlock_return_error();
return err;
}
tr_info("Activate PDP context %d", _cid);