[UTC][softap][Non-ACR][Check profile name using system-info API] 21/211921/1
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 12 Aug 2019 04:45:27 +0000 (13:45 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Mon, 12 Aug 2019 04:47:27 +0000 (13:47 +0900)
http://suprem.sec.samsung.net/jira/browse/TFDF-3540

Change-Id: I62b6cbbb7bbe7b7cc360ee85ec7fd9360ac9dc55
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
src/utc/softap/CMakeLists.txt
src/utc/softap/utc-network-softap-utils.c [new file with mode: 0755]
src/utc/softap/utc-network-softap-utils.h [new file with mode: 0644]
src/utc/softap/utc-network-softap.c

index 1f3c37c1ab20ab35b696bf909a66cf150c00f609..0b21a79904d99508f1e25842fb1ca85b7bc62685 100755 (executable)
@@ -6,6 +6,7 @@ SET(RPM_NAME "core-${PKG_NAME}-tests")
 SET(CAPI_LIB "capi-network-softap")
 SET(TC_SOURCES
     utc-network-softap.c
+       utc-network-softap-utils.c
 )
 
 PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
@@ -38,4 +39,4 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -Wl,-fsanitize=
 ELSE()
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -Wall")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -pie")
-ENDIF()
\ No newline at end of file
+ENDIF()
diff --git a/src/utc/softap/utc-network-softap-utils.c b/src/utc/softap/utc-network-softap-utils.c
new file mode 100755 (executable)
index 0000000..74c717b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utc-network-softap-utils.h"
+
+#include <system_info.h>
+
+#define SYSTEM_INFO_FEATURE_PROFILE "http://tizen.org/feature/profile"
+
+int softap_utils_check_profile(const char *profile)
+{
+       int check = 0;
+       char *current_profile = NULL;
+       int ret = system_info_get_platform_string(SYSTEM_INFO_FEATURE_PROFILE, &current_profile);
+       if (ret == SYSTEM_INFO_ERROR_NONE && profile && current_profile) {
+               if (!strncmp(profile, current_profile, strlen(profile)))
+                       check = 1;
+       }
+
+       if (current_profile)
+               free(current_profile);
+
+       return check;
+}
diff --git a/src/utc/softap/utc-network-softap-utils.h b/src/utc/softap/utc-network-softap-utils.h
new file mode 100644 (file)
index 0000000..6e15316
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UTC_SOFTAP_UTILS_H__
+#define __UTC_SOFTAP_UTILS_H__
+
+#define MOBILE_PROFILE "mobile"
+
+int softap_utils_check_profile(const char *profile);
+
+#endif // __UTC_SOFTAP_UTILS_H__
index 7a6a63d120f413afd80b278a9122bb03a0c3ef32..f5cd35477895b8acb45b17cc6e61ad92592a290b 100755 (executable)
@@ -1,4 +1,6 @@
 #include "assert.h"
+#include "utc-network-softap-utils.h"
+
 #include <softap.h>
 #include <glib.h>
 #include <time.h>
@@ -1153,11 +1155,11 @@ int utc_softap_push_wps_button_n(void)
                return 0;
        }
 
-#if defined(MOBILE)
-       assert_eq(ret, SOFTAP_ERROR_OPERATION_FAILED);
-#else
-       assert_eq(ret, SOFTAP_ERROR_NOT_PERMITTED);
-#endif
+       if (softap_utils_check_profile(MOBILE_PROFILE))
+               assert_eq(ret, SOFTAP_ERROR_OPERATION_FAILED);
+       else
+               assert_eq(ret, SOFTAP_ERROR_NOT_PERMITTED);
+
        ret = softap_push_wps_button(NULL);
        assert_eq(ret, SOFTAP_ERROR_INVALID_PARAMETER);
 
@@ -1176,11 +1178,11 @@ int utc_softap_set_wps_pin_n(void)
                return 0;
        }
 
-#if defined(MOBILE)
-       assert_eq(ret, SOFTAP_ERROR_OPERATION_FAILED);
-#else
-       assert_eq(ret, SOFTAP_ERROR_NOT_PERMITTED);
-#endif
+       if (softap_utils_check_profile(MOBILE_PROFILE))
+               assert_eq(ret, SOFTAP_ERROR_OPERATION_FAILED);
+       else
+               assert_eq(ret, SOFTAP_ERROR_NOT_PERMITTED);
+
        ret = softap_set_wps_pin(NULL, pin);
        assert_eq(ret, SOFTAP_ERROR_INVALID_PARAMETER);
        ret = softap_set_wps_pin(handle, NULL);