{"action":"created","issue":{"url":"https://api.github.com/repos/zaproxy/zaproxy/issues/2715","repository_url":"https://api.github.com/repos/zaproxy/zaproxy","labels_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/2715/labels{/name}","comments_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/2715/comments","events_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/2715/events","html_url":"https://github.com/zaproxy/zaproxy/pull/2715","id":167596839,"number":2715,"title":"Unit tests for the UsernamePasswordAuthenticationCredentials class","user":{"login":"vahidR","id":471521,"avatar_url":"https://avatars.githubusercontent.com/u/471521?v=3","gravatar_id":"","url":"https://api.github.com/users/vahidR","html_url":"https://github.com/vahidR","followers_url":"https://api.github.com/users/vahidR/followers","following_url":"https://api.github.com/users/vahidR/following{/other_user}","gists_url":"https://api.github.com/users/vahidR/gists{/gist_id}","starred_url":"https://api.github.com/users/vahidR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vahidR/subscriptions","organizations_url":"https://api.github.com/users/vahidR/orgs","repos_url":"https://api.github.com/users/vahidR/repos","events_url":"https://api.github.com/users/vahidR/events{/privacy}","received_events_url":"https://api.github.com/users/vahidR/received_events","type":"User","site_admin":false},"labels":[{"id":220536002,"url":"https://api.github.com/repos/zaproxy/zaproxy/labels/Type-Task","name":"Type-Task","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":25,"created_at":"2016-07-26T12:38:10Z","updated_at":"2016-12-03T12:44:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/2715","html_url":"https://github.com/zaproxy/zaproxy/pull/2715","diff_url":"https://github.com/zaproxy/zaproxy/pull/2715.diff","patch_url":"https://github.com/zaproxy/zaproxy/pull/2715.patch"},"body":"Here is the unit tests for the UsernamePasswordAuthenticationCredentials class.\n_Junit_ and _Mockito_ libraries has been called and used. \n"},"comment":{"url":"https://api.github.com/repos/zaproxy/zaproxy/issues/comments/264637210","html_url":"https://github.com/zaproxy/zaproxy/pull/2715#issuecomment-264637210","issue_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/2715","id":264637210,"user":{"login":"thc202","id":4639210,"avatar_url":"https://avatars.githubusercontent.com/u/4639210?v=3","gravatar_id":"","url":"https://api.github.com/users/thc202","html_url":"https://github.com/thc202","followers_url":"https://api.github.com/users/thc202/followers","following_url":"https://api.github.com/users/thc202/following{/other_user}","gists_url":"https://api.github.com/users/thc202/gists{/gist_id}","starred_url":"https://api.github.com/users/thc202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thc202/subscriptions","organizations_url":"https://api.github.com/users/thc202/orgs","repos_url":"https://api.github.com/users/thc202/repos","events_url":"https://api.github.com/users/thc202/events{/privacy}","received_events_url":"https://api.github.com/users/thc202/received_events","type":"User","site_admin":false},"created_at":"2016-12-03T12:44:32Z","updated_at":"2016-12-03T12:44:32Z","body":"Rebased the branch and addressed the previous comments. Following the diff of the changes:\r\n```diff\r\ndiff --git a/src/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentials.java b/src/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentials.java\r\nindex 3706e8b..9287de1 100644\r\n--- a/src/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentials.java\r\n+++ b/src/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentials.java\r\n@@ -85,7 +85,8 @@ class UsernamePasswordAuthenticationCredentials implements AuthenticationCredent\r\n \t@Override\r\n \tpublic String encode(String parentStringSeparator) {\r\n \t\tif (FIELD_SEPARATOR.equals(parentStringSeparator)) {\r\n-\t\t\tthrow new IllegalArgumentException(\"The string separator must not be the same as Field Separator (~).\");\r\n+\t\t\tthrow new IllegalArgumentException(\r\n+\t\t\t\t\t\"The string separator must not be the same as Field Separator (\" + FIELD_SEPARATOR + \").\");\r\n \t\t}\r\n \t\tif (username == null) {\r\n \t\t\treturn NULL_CREDENTIALS;\r\ndiff --git a/test/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentialsUnitTest.java b/test/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentialsUnitTest.java\r\nindex 02f6e0f..d2076b3 100644\r\n--- a/test/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentialsUnitTest.java\r\n+++ b/test/org/zaproxy/zap/authentication/UsernamePasswordAuthenticationCredentialsUnitTest.java\r\n@@ -51,7 +51,7 @@ public class UsernamePasswordAuthenticationCredentialsUnitTest {\r\n     }\r\n \r\n     @Test\r\n-    public void shouldBeConfiguredIfUsernameAndPasswordAreNotNull() throws Exception {\r\n+    public void shouldBeConfiguredIfUsernameAndPasswordAreNotNull() {\r\n         // Given/When\r\n         boolean isConfigured = usernamePasswordAuthenticationCredentials.isConfigured();\r\n \r\n@@ -60,7 +60,7 @@ public class UsernamePasswordAuthenticationCredentialsUnitTest {\r\n     }\r\n \r\n     @Test\r\n-    public void shouldNotBeConfiguredIfUsernameAndPasswordAreNull() throws Exception {\r\n+    public void shouldNotBeConfiguredIfUsernameAndPasswordAreNull() {\r\n         // Given/When\r\n         boolean isConfigured = notConfiguredInstance.isConfigured();\r\n \r\n@@ -68,8 +68,18 @@ public class UsernamePasswordAuthenticationCredentialsUnitTest {\r\n         assertThat(isConfigured, is(false));\r\n     }\r\n \r\n+    @Test\r\n+    public void shouldNotBeConfiguredIfPasswordIsNull() {\r\n+        // Given\r\n+        UsernamePasswordAuthenticationCredentials credentials = new UsernamePasswordAuthenticationCredentials(username, null);\r\n+        // When\r\n+        boolean isConfigured = notConfiguredInstance.isConfigured();\r\n+        // Then\r\n+        assertThat(isConfigured, is(false));\r\n+    }\r\n+\r\n     @Test(expected = IllegalArgumentException.class)\r\n-    public void shouldThrowExceptionWhileEncodeWithFieldSeparator() throws Exception {\r\n+    public void shouldThrowExceptionWhileEncodeWithFieldSeparator() {\r\n         // Given\r\n         String fieldSeparator = \"~\";\r\n         usernamePasswordAuthenticationCredentials = new UsernamePasswordAuthenticationCredentials(username, password);\r\n@@ -81,7 +91,7 @@ public class UsernamePasswordAuthenticationCredentialsUnitTest {\r\n     }\r\n \r\n     @Test\r\n-    public void shouldEncodeMethodReturnNullPatternIfUsernameIsNull() throws Exception {\r\n+    public void shouldEncodeMethodReturnNullPatternIfUsernameIsNull() {\r\n         // Given\r\n         String nullPattern = \"AA==\";\r\n         username = null;\r\n@@ -97,7 +107,7 @@ public class UsernamePasswordAuthenticationCredentialsUnitTest {\r\n     }\r\n \r\n     @Test\r\n-    public void shouldEncodeUsernameAndPasswordWithTheCorrectFieldSeparator() throws Exception {\r\n+    public void shouldEncodeUsernameAndPasswordWithTheCorrectFieldSeparator() {\r\n         // Given\r\n         List<String> someCorrectSeparators = Arrays.asList(\"-\", \"|\", \"/\", \"\\\\\", \"+\");\r\n \r\n@@ -114,7 +124,7 @@ public class UsernamePasswordAuthenticationCredentialsUnitTest {\r\n     }\r\n \r\n     @Test\r\n-    public void shouldApiResponseRepresentationReturnApiResponseWithValidNameAndJsonFormat() throws Exception {\r\n+    public void shouldApiResponseRepresentationReturnApiResponseWithValidNameAndJsonFormat() {\r\n         // Given/When\r\n         ApiResponse apiResponse = usernamePasswordAuthenticationCredentials.getApiResponseRepresentation();\r\n         JSON jsonRepresentation = apiResponse.toJSON();\r\n@@ -122,7 +132,13 @@ public class UsernamePasswordAuthenticationCredentialsUnitTest {\r\n         // Then\r\n         assertThat(apiResponse, notNullValue());\r\n         assertThat(apiResponse.getName(), equalToIgnoringCase(\"credentials\"));\r\n-        assertThat(jsonRepresentation.toString(), allOf(containsString(\"myPass\"), containsString(\"myUser\"), containsString(\"type\")));\r\n+        assertThat(jsonRepresentation.toString(), allOf(\r\n+                containsString(\"username\"),\r\n+                containsString(username),\r\n+                containsString(\"password\"),\r\n+                containsString(password),\r\n+                containsString(\"type\"),\r\n+                containsString(\"UsernamePasswordAuthenticationCredentials\")));\r\n \r\n     }\r\n }\r\n\\ No newline at end of file\r\n```"}}
{"actor":{"display_login":"thc202"}}