Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
levy5307 committed Nov 6, 2020
1 parent c928bd5 commit 28b6c47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/format-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SRC_FILES=(src/main/java/com/xiaomi/infra/pegasus/client/*.java
src/test/java/com/xiaomi/infra/pegasus/rpc/async/*.java
src/test/java/com/xiaomi/infra/pegasus/tools/*.java
src/test/java/com/xiaomi/infra/pegasus/base/*.java
src/test/java/com/xiaomi/infra/pegasus/security/*.java
)

if [ ! -f "${PROJECT_DIR}"/google-java-format-1.7-all-deps.jar ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void onRecvMechanisms(negotiation_response response) throws Exception {

String[] matchMechanisms = new String[1];
matchMechanisms[0] = getMatchMechanism(new String(response.msg.data, Charset.defaultCharset()));
if (matchMechanisms[0] == null) {
if (matchMechanisms[0] == "") {
throw new Exception("No matching mechanism was found");
}

Expand All @@ -116,7 +116,7 @@ public void onRecvMechanisms(negotiation_response response) throws Exception {
}

public String getMatchMechanism(String respString) {
String matchMechanism = null;
String matchMechanism = "";
String[] serverSupportMechanisms = respString.split(",");
for (String serverSupportMechanism : serverSupportMechanisms) {
if (expectedMechanisms.contains(serverSupportMechanism)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.xiaomi.infra.pegasus.apps.negotiation_response;
import com.xiaomi.infra.pegasus.apps.negotiation_status;
import com.xiaomi.infra.pegasus.base.blob;
import java.nio.charset.Charset;
import javax.security.auth.Subject;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -80,12 +81,24 @@ public void testRecvMechanisms() {
() -> {
negotiation_response response =
new negotiation_response(
negotiation_status.SASL_LIST_MECHANISMS_RESP, new blob(new byte[0]));
negotiation_status.SASL_LIST_MECHANISMS_RESP,
new blob("GSSAPI".getBytes(Charset.defaultCharset())));
mockNegotiation.onRecvMechanisms(response);
Assert.assertEquals(
mockNegotiation.getStatus(), negotiation_status.SASL_SELECT_MECHANISMS);
});

// deal with wrong response.msg
Assertions.assertThrows(
Exception.class,
() -> {
negotiation_response response =
new negotiation_response(
negotiation_status.SASL_LIST_MECHANISMS,
new blob("NOTSUPPORTED".getBytes(Charset.defaultCharset())));
mockNegotiation.onRecvMechanisms(response);
});

// deal with wrong response.status
Assertions.assertThrows(
Exception.class,
Expand Down

0 comments on commit 28b6c47

Please sign in to comment.