[Security][TCSACR-317][Change behavior of GetDisplayName and GetDescription] 20/236920/5
authorYunjin Lee <yunjin-.lee@samsung.com>
Tue, 26 May 2020 05:07:11 +0000 (14:07 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Tue, 14 Jul 2020 06:16:37 +0000 (15:16 +0900)
- Change to throw ArgumentException when the given privilege isn't exist
on the target.

Change-Id: I345b7de3ffa3499230cdf0f79381933dd4a4ff9a
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
tct-suite-vs/Tizen.Privilege.Tests/testcase/TSPrivilege.cs

index 84bee2b..d9d8c45 100755 (executable)
@@ -89,81 +89,101 @@ namespace Tizen.Security.Tests
         }
 
         [Test]
-        [Category("P3")]
-        [Description("Get privilege display name with not defined privilege")]
+        [Category("P2")]
+        [Description("Get privilege display name with not defined privilege to check ArgumentException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDisplayName M")]
         [Property("SPEC_URL", "-")]
-        [Property("CRITERIA", "MR")]
+        [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string")]
-        public void GetDisplayName_NOT_DEFINED_RETURN_VALUE()
+        public void GetDisplayName_RETURN_ARGUMENT_EXCEPTION()
         {
             try
             {
                 var ret = Privilege.GetDisplayName(apiVersion, notDefinedPrivilege);
-                Assert.IsInstanceOf<string>(ret, "Display name should be string type.");
-                Assert.IsNotNull(ret, "Display name should not be null.");
-                Assert.IsTrue(ret.Length >= 0, "Length of display name should be greater than 0.");
+                Assert.Fail("Expects to throw ArgumentException exception when not defined privilege inputted, but exception not thrown");
             }
             catch (Exception e)
             {
-                Assert.Fail("Privilege.GetDisplayName: " + e.ToString());
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentException"), "GetDisplayName does not accept unknown privilege input.");
+
             }
         }
 
         [Test]
-        [Category("P3")]
-        [Description("Get privilege display name with package type with not defined privilege")]
+        [Category("P2")]
+        [Description("Get privilege display name with package type with not defined privilege to check ArgumentException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDisplayName M")]
         [Property("SPEC_URL", "-")]
-        [Property("CRITERIA", "MR")]
+        [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string, Tizen.Applications.PackageType")]
-        public void GetDisplayName_PACKAGETYPE_NOT_DEFINED_RETURN_VALUE()
+        public void GetDisplayName_PACKAGETYPE_RETURN_ARGUMENT_EXCEPTION()
         {
             try
             {
                 var ret = Privilege.GetDisplayName(apiVersion, notDefinedPrivilege, wgt);
-                Assert.IsInstanceOf<string>(ret, "Display name should be string type.");
-                Assert.IsNotNull(ret, "Display name should not be null.");
-                Assert.IsTrue(ret.Length >= 0, "Length of display name should be greater than 0.");
+                Assert.Fail("Expects to throw ArgumentException exception when not defined privilege inputted, but exception not thrown");
             }
             catch (Exception e)
             {
-                Assert.Fail("Privilege.GetDisplayName: " + e.ToString());
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentException"), "GetDisplayName does not accept unknown privilege input.");
             }
         }
 
         [Test]
         [Category("P2")]
-        [Description("Get privilege display name with null input parameter to check ArgumentException exception")]
+        [Description("Get privilege display name with null api-version input parameter to check ArgumentNullException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDisplayName M")]
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string")]
-        public void GetDisplayName_NULL_PARAM()
+        public void GetDisplayName_NULL_PARAM_API_VERSION()
         {
             try
             {
                 var ret = Privilege.GetDisplayName(null, internetPrivilege);
                 Assert.Fail("Expects to throw ArgumentException exception when null inputted for version param, but exception not thrown");
+
             }
             catch (Exception e)
             {
-                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDisplayName does not accept null input.");
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDisplayName does not accept null api-version input.");
             }
         }
 
         [Test]
         [Category("P2")]
-        [Description("Get privilege display name with package type with null input parameter to check ArgumentException exception")]
+        [Description("Get privilege display name with null privilege input parameter to check ArgumentNullException exception")]
+        [Property("SPEC", "Tizen.Security.Privilege.GetDisplayName M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
+        [Property("COVPARAM", "string, string")]
+        public void GetDisplayName_NULL_PARAM_PRIVILEGE()
+        {
+            try
+            {
+                var ret = Privilege.GetDisplayName(apiVersion, null);
+                Assert.Fail("Expects to throw ArgumentException exception when null inputted for privilege param, but exception not thrown");
+
+            }
+            catch (Exception e)
+            {
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDisplayName does not accept null privilege input.");
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Get privilege display name with package type with null api-version input parameter to check ArgumentNullException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDisplayName M")]
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string, Tizen.Applications.PackageType")]
-        public void GetDisplayName_PACKAGETYPE_NULL_PARAM()
+        public void GetDisplayName_PACKAGETYPE_NULL_PARAM_API_VERSION()
         {
             try
             {
@@ -172,7 +192,28 @@ namespace Tizen.Security.Tests
             }
             catch (Exception e)
             {
-                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDisplayName does not accept null input.");
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDisplayName does not accept null api-version input.");
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Get privilege display name with package type with null privilege input parameter to check ArgumentNullException exception")]
+        [Property("SPEC", "Tizen.Security.Privilege.GetDisplayName M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
+        [Property("COVPARAM", "string, string, Tizen.Applications.PackageType")]
+        public void GetDisplayName_PACKAGETYPE_NULL_PARAM_PRIVILEGE()
+        {
+            try
+            {
+                var ret = Privilege.GetDisplayName(apiVersion, null, tpk);
+                Assert.Fail("Expects to throw ArgumentException exception when null inputted for privilege param, but exception not thrown");
+            }
+            catch (Exception e)
+            {
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDisplayName does not accept null privilege input.");
             }
         }
 
@@ -223,65 +264,82 @@ namespace Tizen.Security.Tests
         }
 
         [Test]
-        [Category("P3")]
-        [Description("Get privilege description with not defined privilege")]
+        [Category("P2")]
+        [Description("Get privilege description with not defined privilege to check ArgumentException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDescription M")]
         [Property("SPEC_URL", "-")]
-        [Property("CRITERIA", "MR")]
+        [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string")]
-        public void GetDescription_NOT_DEFINED_RETURN_VALUE()
+        public void GetDescription_RETURN_ARGUMENT_EXCEPTION()
         {
             try
             {
                 var ret = Privilege.GetDescription(apiVersion, notDefinedPrivilege);
-                Assert.IsInstanceOf<string>(ret, "Description should be string type.");
-                Assert.IsNotNull(ret, "Description should not be null.");
-                Assert.IsTrue(ret.Length >= 0, "Length of description should be greater than 0.");
+                Assert.Fail("Expects to throw ArgumentException exception when not defined privilege inputted, but exception not thrown");
             }
             catch (Exception e)
             {
-                Assert.Fail("Privilege.GetDescription: " + e.ToString());
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentException"), "GetDescription does not accept unknown privilege input.");
             }
         }
 
         [Test]
-        [Category("P3")]
-        [Description("Get privilege description with package type with not defined privilege")]
+        [Category("P2")]
+        [Description("Get privilege description with package type with not defined privilege to check ArgumentException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDescription M")]
         [Property("SPEC_URL", "-")]
-        [Property("CRITERIA", "MR")]
+        [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string, Tizen.Applications.PackageType")]
-        public void GetDescription_PACKAGETYPE_NOT_DEFINED_RETURN_VALUE()
+        public void GetDescription_PACKAGETYPE_RETURN_ARGUMENT_EXCEPTION()
         {
             try
             {
                 var ret = Privilege.GetDescription(apiVersion, notDefinedPrivilege, wgt);
-                Assert.IsInstanceOf<string>(ret, "Description should be string type.");
-                Assert.IsNotNull(ret, "Description should not be null.");
-                Assert.IsTrue(ret.Length >= 0, "Length of description should be greater than 0.");
+                Assert.Fail("Expects to throw ArgumentException exception when not defined privilege inputted, but exception not thrown");
             }
             catch (Exception e)
             {
-                Assert.Fail("Privilege.GetDescription: " + e.ToString());
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentException"), "GetDescription does not accept unknown privilege input.");
             }
         }
 
         [Test]
         [Category("P2")]
-        [Description("Get privilege description with null input parameter to check ArgumentException exception")]
+        [Description("Get privilege description with null api-version input parameter to check ArgumentNullException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDescription M")]
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string")]
-        public void GetDescription_NULL_PARAM()
+        public void GetDescription_NULL_PARAM_API_VERSION()
         {
             try
             {
                 var ret = Privilege.GetDescription(null, internetPrivilege);
-                Assert.Fail("Expects to throw ArgumentException exception when null inputted for version param, but exception not thrown");
+                Assert.Fail("Expects to throw ArgumentNullException exception when null inputted for version param, but exception not thrown");
+            }
+            catch (Exception e)
+            {
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDescription does not accept null api-version input.");
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Get privilege description with null privilege input parameter to check ArgumentNullException exception")]
+        [Property("SPEC", "Tizen.Security.Privilege.GetDescription M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
+        [Property("COVPARAM", "string, string")]
+        public void GetDescription_NULL_PARAM_PRIVILEGE()
+        {
+            try
+            {
+                var ret = Privilege.GetDescription(apiVersion, null);
+                Assert.Fail("Expects to throw ArgumentNullException exception when null inputted for privilege param, but exception not thrown");
             }
             catch (Exception e)
             {
@@ -291,22 +349,43 @@ namespace Tizen.Security.Tests
 
         [Test]
         [Category("P2")]
-        [Description("Get privilege description with package type with null input parameter to check ArgumentException exception")]
+        [Description("Get privilege description with package type with null api-version input parameter to check ArgumentNullException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetDescription M")]
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
         [Property("COVPARAM", "string, string, Tizen.Applications.PackageType")]
-        public void GetDescription_PACKAGETYPE_NULL_PARAM()
+        public void GetDescription_PACKAGETYPE_NULL_PARAM_API_VERSION()
         {
             try
             {
                 var ret = Privilege.GetDescription(null, internetPrivilege, tpk);
-                Assert.Fail("Expects to throw ArgumentException exception when null inputted for version param, but exception not thrown");
+                Assert.Fail("Expects to throw ArgumentNullException exception when null inputted for version param, but exception not thrown");
             }
             catch (Exception e)
             {
-                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDescription does not accept null input.");
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDescription does not accept null api-version input.");
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Get privilege description with package type with null privilege input parameter to check ArgumentNullException exception")]
+        [Property("SPEC", "Tizen.Security.Privilege.GetDescription M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Yunjin Lee, yunjin-.lee@samsung.com")]
+        [Property("COVPARAM", "string, string, Tizen.Applications.PackageType")]
+        public void GetDescription_PACKAGETYPE_NULL_PARAM_PRIVILEGE()
+        {
+            try
+            {
+                var ret = Privilege.GetDescription(apiVersion, null, tpk);
+                Assert.Fail("Expects to throw ArgumentNullException exception when null inputted for privilege param, but exception not thrown");
+            }
+            catch (Exception e)
+            {
+                Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetDescription does not accept null privilege input.");
             }
         }
 
@@ -363,7 +442,7 @@ namespace Tizen.Security.Tests
 
         [Test]
         [Category("P2")]
-        [Description("Get privacy display name with null input parameter to check ArgumentException exception")]
+        [Description("Get privacy display name with null input parameter to check ArgumentNullException exception")]
         [Property("SPEC", "Tizen.Security.Privilege.GetPrivacyDisplayName M")]
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "MEX")]
@@ -373,7 +452,7 @@ namespace Tizen.Security.Tests
             try
             {
                 var ret = Privilege.GetPrivacyDisplayName(null);
-                Assert.Fail("Expects to throw ArgumentException exception when null inputted for privilege param, but exception not thrown");
+                Assert.Fail("Expects to throw ArgumentNullException exception when null inputted for privilege param, but exception not thrown");
             }
             catch (NotSupportedException)
             {