{"action":"created","comment":{"url":"https://api.github.com/repos/apache/kafka/pulls/comments/61420454","id":61420454,"diff_hunk":"@@ -0,0 +1,397 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE\n+ * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file\n+ * to You under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the\n+ * License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on\n+ * an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations under the License.\n+ */\n+package org.apache.kafka.common.network;\n+\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Random;\n+import java.net.InetSocketAddress;\n+import java.nio.ByteBuffer;\n+\n+import static org.junit.Assert.fail;\n+\n+import org.apache.kafka.common.KafkaException;\n+import org.apache.kafka.common.config.SaslConfigs;\n+import org.apache.kafka.common.metrics.Metrics;\n+import org.apache.kafka.common.protocol.ApiKeys;\n+import org.apache.kafka.common.protocol.SecurityProtocol;\n+import org.apache.kafka.common.requests.MetadataRequest;\n+import org.apache.kafka.common.requests.RequestHeader;\n+import org.apache.kafka.common.requests.RequestSend;\n+import org.apache.kafka.common.requests.SaslHandshakeRequest;\n+import org.apache.kafka.common.security.plain.PlainLoginModule;\n+import org.apache.kafka.common.utils.MockTime;\n+import org.junit.After;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+/**\n+ * Tests for the Sasl authenticator. These use a test harness that runs a simple socket server that echos back responses.\n+ */\n+public class SaslAuthenticatorTest {\n+\n+    private static final int BUFFER_SIZE = 4 * 1024;\n+\n+    private NioEchoServer server;\n+    private Selector selector;\n+    private ChannelBuilder channelBuilder;\n+    private CertStores serverCertStores;\n+    private CertStores clientCertStores;\n+    private Map<String, Object> saslClientConfigs;\n+    private Map<String, Object> saslServerConfigs;\n+\n+    @Before\n+    public void setup() throws Exception {\n+        serverCertStores = new CertStores(true, \"localhost\");\n+        clientCertStores = new CertStores(false, \"localhost\");\n+        saslServerConfigs = serverCertStores.getTrustingConfig(clientCertStores);\n+        saslClientConfigs = clientCertStores.getTrustingConfig(serverCertStores);\n+    }\n+\n+    @After\n+    public void teardown() throws Exception {\n+        if (server != null)\n+            this.server.close();\n+        if (selector != null)\n+            this.selector.close();\n+    }\n+\n+    /**\n+     * Tests good path SASL/PLAIN client and server channels using SSL transport layer.\n+     */\n+    @Test\n+    public void testValidSaslPlain_Ssl() throws Exception {","path":"clients/src/test/java/org/apache/kafka/common/network/SaslAuthenticatorTest.java","position":75,"original_position":75,"commit_id":"2f8234aae69f3bfbad53cf0e770b430f89faa82d","original_commit_id":"2f8234aae69f3bfbad53cf0e770b430f89faa82d","user":{"login":"ijuma","id":24747,"avatar_url":"https://avatars.githubusercontent.com/u/24747?v=3","gravatar_id":"","url":"https://api.github.com/users/ijuma","html_url":"https://github.com/ijuma","followers_url":"https://api.github.com/users/ijuma/followers","following_url":"https://api.github.com/users/ijuma/following{/other_user}","gists_url":"https://api.github.com/users/ijuma/gists{/gist_id}","starred_url":"https://api.github.com/users/ijuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ijuma/subscriptions","organizations_url":"https://api.github.com/users/ijuma/orgs","repos_url":"https://api.github.com/users/ijuma/repos","events_url":"https://api.github.com/users/ijuma/events{/privacy}","received_events_url":"https://api.github.com/users/ijuma/received_events","type":"User","site_admin":false},"body":"We don't usually use underscores in our method names. Maybe this could be `testValidSaslPlainOverSsl` or something like that?","created_at":"2016-04-28T12:46:13Z","updated_at":"2016-04-28T12:46:13Z","html_url":"https://github.com/apache/kafka/pull/1273#discussion_r61420454","pull_request_url":"https://api.github.com/repos/apache/kafka/pulls/1273","_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments/61420454"},"html":{"href":"https://github.com/apache/kafka/pull/1273#discussion_r61420454"},"pull_request":{"href":"https://api.github.com/repos/apache/kafka/pulls/1273"}}},"pull_request":{"url":"https://api.github.com/repos/apache/kafka/pulls/1273","id":68035749,"html_url":"https://github.com/apache/kafka/pull/1273","diff_url":"https://github.com/apache/kafka/pull/1273.diff","patch_url":"https://github.com/apache/kafka/pull/1273.patch","issue_url":"https://api.github.com/repos/apache/kafka/issues/1273","number":1273,"state":"open","locked":false,"title":"KAFKA-3617: Unit tests for SASL authenticator","user":{"login":"rajinisivaram","id":13164074,"avatar_url":"https://avatars.githubusercontent.com/u/13164074?v=3","gravatar_id":"","url":"https://api.github.com/users/rajinisivaram","html_url":"https://github.com/rajinisivaram","followers_url":"https://api.github.com/users/rajinisivaram/followers","following_url":"https://api.github.com/users/rajinisivaram/following{/other_user}","gists_url":"https://api.github.com/users/rajinisivaram/gists{/gist_id}","starred_url":"https://api.github.com/users/rajinisivaram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajinisivaram/subscriptions","organizations_url":"https://api.github.com/users/rajinisivaram/orgs","repos_url":"https://api.github.com/users/rajinisivaram/repos","events_url":"https://api.github.com/users/rajinisivaram/events{/privacy}","received_events_url":"https://api.github.com/users/rajinisivaram/received_events","type":"User","site_admin":false},"body":"Unit tests for SASL authenticator, tests for SASL/PLAIN and multiple mechanisms, authorization test for SASL/PLAIN","created_at":"2016-04-27T11:12:25Z","updated_at":"2016-04-28T12:46:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5434624057e020ab220564f6b7aeafa3cb4343ed","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/kafka/pulls/1273/commits","review_comments_url":"https://api.github.com/repos/apache/kafka/pulls/1273/comments","review_comment_url":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/kafka/issues/1273/comments","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/2f8234aae69f3bfbad53cf0e770b430f89faa82d","head":{"label":"rajinisivaram:KAFKA-3617","ref":"KAFKA-3617","sha":"2f8234aae69f3bfbad53cf0e770b430f89faa82d","user":{"login":"rajinisivaram","id":13164074,"avatar_url":"https://avatars.githubusercontent.com/u/13164074?v=3","gravatar_id":"","url":"https://api.github.com/users/rajinisivaram","html_url":"https://github.com/rajinisivaram","followers_url":"https://api.github.com/users/rajinisivaram/followers","following_url":"https://api.github.com/users/rajinisivaram/following{/other_user}","gists_url":"https://api.github.com/users/rajinisivaram/gists{/gist_id}","starred_url":"https://api.github.com/users/rajinisivaram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajinisivaram/subscriptions","organizations_url":"https://api.github.com/users/rajinisivaram/orgs","repos_url":"https://api.github.com/users/rajinisivaram/repos","events_url":"https://api.github.com/users/rajinisivaram/events{/privacy}","received_events_url":"https://api.github.com/users/rajinisivaram/received_events","type":"User","site_admin":false},"repo":{"id":42296329,"name":"kafka","full_name":"rajinisivaram/kafka","owner":{"login":"rajinisivaram","id":13164074,"avatar_url":"https://avatars.githubusercontent.com/u/13164074?v=3","gravatar_id":"","url":"https://api.github.com/users/rajinisivaram","html_url":"https://github.com/rajinisivaram","followers_url":"https://api.github.com/users/rajinisivaram/followers","following_url":"https://api.github.com/users/rajinisivaram/following{/other_user}","gists_url":"https://api.github.com/users/rajinisivaram/gists{/gist_id}","starred_url":"https://api.github.com/users/rajinisivaram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajinisivaram/subscriptions","organizations_url":"https://api.github.com/users/rajinisivaram/orgs","repos_url":"https://api.github.com/users/rajinisivaram/repos","events_url":"https://api.github.com/users/rajinisivaram/events{/privacy}","received_events_url":"https://api.github.com/users/rajinisivaram/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rajinisivaram/kafka","description":"Mirror of Apache Kafka","fork":true,"url":"https://api.github.com/repos/rajinisivaram/kafka","forks_url":"https://api.github.com/repos/rajinisivaram/kafka/forks","keys_url":"https://api.github.com/repos/rajinisivaram/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rajinisivaram/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rajinisivaram/kafka/teams","hooks_url":"https://api.github.com/repos/rajinisivaram/kafka/hooks","issue_events_url":"https://api.github.com/repos/rajinisivaram/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/rajinisivaram/kafka/events","assignees_url":"https://api.github.com/repos/rajinisivaram/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/rajinisivaram/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/rajinisivaram/kafka/tags","blobs_url":"https://api.github.com/repos/rajinisivaram/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rajinisivaram/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rajinisivaram/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/rajinisivaram/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rajinisivaram/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/rajinisivaram/kafka/languages","stargazers_url":"https://api.github.com/repos/rajinisivaram/kafka/stargazers","contributors_url":"https://api.github.com/repos/rajinisivaram/kafka/contributors","subscribers_url":"https://api.github.com/repos/rajinisivaram/kafka/subscribers","subscription_url":"https://api.github.com/repos/rajinisivaram/kafka/subscription","commits_url":"https://api.github.com/repos/rajinisivaram/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/rajinisivaram/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/rajinisivaram/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/rajinisivaram/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/rajinisivaram/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/rajinisivaram/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rajinisivaram/kafka/merges","archive_url":"https://api.github.com/repos/rajinisivaram/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rajinisivaram/kafka/downloads","issues_url":"https://api.github.com/repos/rajinisivaram/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/rajinisivaram/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/rajinisivaram/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/rajinisivaram/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rajinisivaram/kafka/labels{/name}","releases_url":"https://api.github.com/repos/rajinisivaram/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/rajinisivaram/kafka/deployments","created_at":"2015-09-11T08:16:17Z","updated_at":"2016-01-29T12:19:37Z","pushed_at":"2016-04-28T10:58:29Z","git_url":"git://github.com/rajinisivaram/kafka.git","ssh_url":"git@github.com:rajinisivaram/kafka.git","clone_url":"https://github.com/rajinisivaram/kafka.git","svn_url":"https://github.com/rajinisivaram/kafka","homepage":null,"size":29814,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"8407dac6ee409d832c95533e6f1d5578511232ae","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":2211243,"name":"kafka","full_name":"apache/kafka","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/kafka","description":"Mirror of Apache Kafka","fork":false,"url":"https://api.github.com/repos/apache/kafka","forks_url":"https://api.github.com/repos/apache/kafka/forks","keys_url":"https://api.github.com/repos/apache/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/kafka/teams","hooks_url":"https://api.github.com/repos/apache/kafka/hooks","issue_events_url":"https://api.github.com/repos/apache/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/apache/kafka/events","assignees_url":"https://api.github.com/repos/apache/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/apache/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/apache/kafka/tags","blobs_url":"https://api.github.com/repos/apache/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/kafka/languages","stargazers_url":"https://api.github.com/repos/apache/kafka/stargazers","contributors_url":"https://api.github.com/repos/apache/kafka/contributors","subscribers_url":"https://api.github.com/repos/apache/kafka/subscribers","subscription_url":"https://api.github.com/repos/apache/kafka/subscription","commits_url":"https://api.github.com/repos/apache/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/apache/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/kafka/merges","archive_url":"https://api.github.com/repos/apache/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/kafka/downloads","issues_url":"https://api.github.com/repos/apache/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/apache/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/kafka/labels{/name}","releases_url":"https://api.github.com/repos/apache/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/apache/kafka/deployments","created_at":"2011-08-15T18:06:16Z","updated_at":"2016-04-28T09:59:25Z","pushed_at":"2016-04-28T11:35:10Z","git_url":"git://github.com/apache/kafka.git","ssh_url":"git@github.com:apache/kafka.git","clone_url":"https://github.com/apache/kafka.git","svn_url":"https://github.com/apache/kafka","homepage":null,"size":40291,"stargazers_count":3020,"watchers_count":3020,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1816,"mirror_url":"git://git.apache.org/kafka.git","open_issues_count":182,"forks":1816,"open_issues":182,"watchers":3020,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/1273"},"html":{"href":"https://github.com/apache/kafka/pull/1273"},"issue":{"href":"https://api.github.com/repos/apache/kafka/issues/1273"},"comments":{"href":"https://api.github.com/repos/apache/kafka/issues/1273/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/kafka/pulls/1273/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/kafka/pulls/1273/commits"},"statuses":{"href":"https://api.github.com/repos/apache/kafka/statuses/2f8234aae69f3bfbad53cf0e770b430f89faa82d"}}}}