Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MDeLuise authored and Coduz committed Nov 24, 2022
1 parent 7b1afc8 commit e515bf6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,35 @@ Scenario: Init Security Context for all scenarios
Then No exception was thrown
Then I logout

Scenario: Creating a device with disabled status and trying to connect to the broker.
Login as kapua-sys, create a device with its status set to DISABLED.
Then, trying to connect to the broker with a client who's client id equals to the created
device. Should result in an authentication failure.

When I login as user with name "kapua-sys" and password "kapua-password"
And I create a device with parameters
| clientId | displayName | modelId | serialNumber | status | scopeId |
| dev-123 | dply-Name_123@#$% | ReliaGate 10-20 | 12541234ABC | DISABLED | 1 |
Then No exception was thrown
Then I logout
Given I expect the exception "MqttSecurityException" with the text "Not authorized to connect"
When Client with name "dev-123" with client id "dev-123" user "kapua-broker" password "kapua-password" is connected
Then An exception was thrown

Scenario: Creating a device with enabled status and trying to connect to the broker.
Login as kapua-sys, create a device with its status set to ENABLED.
Then, trying to connect to the broker with a client who's client id equals to the created
device. Should not result in an authentication failure.

When I login as user with name "kapua-sys" and password "kapua-password"
And I create a device with parameters
| clientId | displayName | modelId | serialNumber | status | scopeId |
| dev-123 | dply-Name_123@#$% | ReliaGate 10-20 | 12541234ABC | ENABLED | 1 |
Then No exception was thrown
Then I logout
When Client with name "dev-12" with client id "dev-12" user "kapua-broker" password "kapua-password" is connected
Then No exception was thrown

Scenario: Creating A Device With Enabled Status
Login as kapua-sys, go to devices, create a device with its status set to ENABLED.
Kapua should not return errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,19 +483,14 @@ public void deviceWithServerIp(String serverIp) {
public void clientConnect(String clientName, String clientId, String user, String password) throws Exception {
MqttClient mqttClient = null;
MqttConnectOptions clientOpts = new MqttConnectOptions();

try {
mqttClient = new MqttClient(BROKER_URI, clientId,
new MemoryPersistence());
} catch (MqttException e) {
e.printStackTrace();
}
clientOpts.setUserName(user);
clientOpts.setPassword(password.toCharArray());
primeException();
try {
mqttClient = new MqttClient(BROKER_URI, clientId, new MemoryPersistence());
clientOpts.setUserName(user);
clientOpts.setPassword(password.toCharArray());
mqttClient.connect(clientOpts);
} catch (MqttException e) {
e.printStackTrace();
verifyException(e);
}
if (mqttClient != null) {
stepData.put(clientName, mqttClient);
Expand Down

0 comments on commit e515bf6

Please sign in to comment.