Skip to content

Commit 1466512

Browse files
yufengwangcapull[bot]
authored andcommitted
[CI] Add test to check establish PASE connection only Java API (#25120)
1 parent 2431637 commit 1466512

File tree

7 files changed

+74
-2
lines changed

7 files changed

+74
-2
lines changed

.github/workflows/tests.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,18 @@ jobs:
570570
--tool-args "already-discovered --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \
571571
--factoryreset \
572572
'
573+
- name: Run Pairing Address-PaseOnly Test
574+
timeout-minutes: 10
575+
run: |
576+
scripts/run_in_build_env.sh \
577+
'./scripts/tests/run_java_test.py \
578+
--app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
579+
--app-args "--discriminator 3840 --interface-id -1" \
580+
--tool-path out/linux-x64-java-matter-controller \
581+
--tool-cluster "pairing" \
582+
--tool-args "address-paseonly --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \
583+
--factoryreset \
584+
'
573585
- name: Uploading core files
574586
uses: actions/upload-artifact@v3
575587
if: ${{ failure() && !env.ACT }}

examples/java-matter-controller/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ java_binary("java-matter-controller") {
4242
"java/src/com/matter/controller/commands/discover/DiscoverCommissionersCommand.java",
4343
"java/src/com/matter/controller/commands/pairing/CloseSessionCommand.java",
4444
"java/src/com/matter/controller/commands/pairing/DiscoveryFilterType.java",
45+
"java/src/com/matter/controller/commands/pairing/PairAddressPaseCommand.java",
4546
"java/src/com/matter/controller/commands/pairing/PairAlreadyDiscoveredCommand.java",
4647
"java/src/com/matter/controller/commands/pairing/PairCodeCommand.java",
4748
"java/src/com/matter/controller/commands/pairing/PairCodePaseCommand.java",

examples/java-matter-controller/java/src/com/matter/controller/Main.java

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ private static void registerCommandsPairing(
6060
new PairCodeWifiCommand(controller, credentialsIssuer);
6161
PairCodeThreadCommand pairCodeThreadCommand =
6262
new PairCodeThreadCommand(controller, credentialsIssuer);
63+
PairAddressPaseCommand pairAddressPaseCommand =
64+
new PairAddressPaseCommand(controller, credentialsIssuer);
6365
PairAlreadyDiscoveredCommand pairAlreadyDiscoveredCommand =
6466
new PairAlreadyDiscoveredCommand(controller, credentialsIssuer);
6567
PairOnNetworkCommand pairOnNetworkCommand =
@@ -83,6 +85,7 @@ private static void registerCommandsPairing(
8385
clusterCommands.add(pairCodePaseCommand);
8486
clusterCommands.add(pairCodeWifiCommand);
8587
clusterCommands.add(pairCodeThreadCommand);
88+
clusterCommands.add(pairAddressPaseCommand);
8689
clusterCommands.add(pairAlreadyDiscoveredCommand);
8790
clusterCommands.add(pairOnNetworkCommand);
8891
clusterCommands.add(pairOnNetworkShortCommand);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.matter.controller.commands.pairing;
2+
3+
import chip.devicecontroller.ChipDeviceController;
4+
import com.matter.controller.commands.common.CredentialsIssuer;
5+
import java.util.logging.Level;
6+
import java.util.logging.Logger;
7+
8+
public final class PairAddressPaseCommand extends PairingCommand {
9+
private static Logger logger = Logger.getLogger(PairAddressPaseCommand.class.getName());
10+
11+
public PairAddressPaseCommand(ChipDeviceController controller, CredentialsIssuer credsIssue) {
12+
super(
13+
controller,
14+
"address-paseonly",
15+
PairingModeType.ADDRESS_PASE_ONLY,
16+
PairingNetworkType.NONE,
17+
credsIssue);
18+
}
19+
20+
@Override
21+
public void onPairingComplete(int errorCode) {
22+
logger.log(Level.INFO, "onPairingComplete with error code: " + errorCode);
23+
if (errorCode == 0) {
24+
setSuccess();
25+
} else {
26+
setFailure("onPairingComplete failure");
27+
}
28+
}
29+
30+
@Override
31+
protected void runCommand() {
32+
currentCommissioner()
33+
.establishPaseConnection(
34+
getNodeId(), getRemoteAddr().getHostAddress(), getRemotePort(), getSetupPINCode());
35+
36+
currentCommissioner().setCompletionListener(this);
37+
waitCompleteMs(getTimeoutMillis());
38+
}
39+
}

examples/java-matter-controller/java/src/com/matter/controller/commands/pairing/PairingCommand.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,15 @@ public PairingCommand(
189189
break;
190190
case CODE:
191191
case CODE_PASE_ONLY:
192-
Only:
193192
addArgument("payload", mOnboardingPayload, null, false);
194193
addArgument("discover-once", mDiscoverOnce, null, false);
195194
addArgument("use-only-onnetwork-discovery", mUseOnlyOnNetworkDiscovery, null, false);
196195
break;
196+
case ADDRESS_PASE_ONLY:
197+
addArgument("setup-pin-code", 0, 134217727, mSetupPINCode, null, false);
198+
addArgument("device-remote-ip", mRemoteAddr, false);
199+
addArgument("device-remote-port", (short) 0, Short.MAX_VALUE, mRemotePort, null, false);
200+
break;
197201
case BLE:
198202
addArgument("setup-pin-code", 0, 134217727, mSetupPINCode, null, false);
199203
addArgument("discriminator", (short) 0, (short) 4096, mDiscriminator, null, false);
@@ -202,7 +206,6 @@ public PairingCommand(
202206
addArgument("setup-pin-code", 0, 134217727, mSetupPINCode, null, false);
203207
break;
204208
case SOFT_AP:
205-
AP:
206209
addArgument("setup-pin-code", 0, 134217727, mSetupPINCode, null, false);
207210
addArgument("discriminator", (short) 0, (short) 4096, mDiscriminator, null, false);
208211
addArgument("device-remote-ip", mRemoteAddr, false);

examples/java-matter-controller/java/src/com/matter/controller/commands/pairing/PairingModeType.java

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum PairingModeType {
2222
NONE,
2323
CODE,
2424
CODE_PASE_ONLY,
25+
ADDRESS_PASE_ONLY,
2526
BLE,
2627
SOFT_AP,
2728
ALREADY_DISCOVERED,

scripts/tests/java/commissioning_test.py

+13
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ def TestCmdAlreadyDiscovered(self, nodeid, setuppin, address, port, timeout):
8181
DumpProgramOutputToQueue(self.thread_list, Fore.GREEN + "JAVA " + Style.RESET_ALL, java_process, self.queue)
8282
return java_process.wait()
8383

84+
def TestCmdAddressPaseOnly(self, nodeid, setuppin, address, port, timeout):
85+
java_command = self.command + ['pairing', 'address-paseonly', nodeid, setuppin, address, port, timeout]
86+
logging.info(f"Execute: {java_command}")
87+
java_process = subprocess.Popen(
88+
java_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
89+
DumpProgramOutputToQueue(self.thread_list, Fore.GREEN + "JAVA " + Style.RESET_ALL, java_process, self.queue)
90+
return java_process.wait()
91+
8492
def RunTest(self):
8593
if self.command_name == 'onnetwork-long':
8694
logging.info("Testing pairing onnetwork-long")
@@ -92,5 +100,10 @@ def RunTest(self):
92100
code = self.TestCmdAlreadyDiscovered(self.nodeid, self.setup_pin_code, self.address, self.port, self.timeout)
93101
if code != 0:
94102
raise Exception(f"Testing pairing already-discovered failed with error {code}")
103+
elif self.command_name == 'address-paseonly':
104+
logging.info("Testing pairing address-paseonly")
105+
code = self.TestCmdAddressPaseOnly(self.nodeid, self.setup_pin_code, self.address, self.port, self.timeout)
106+
if code != 0:
107+
raise Exception(f"Testing pairing address-paseonly failed with error {code}")
95108
else:
96109
raise Exception(f"Unsupported command {self.command_name}")

0 commit comments

Comments
 (0)