Browse Source

Lwm2m Fix bug review edit tests security

pull/5254/head
nickAS21 5 years ago
parent
commit
45921f89f4
  1. 7
      application/src/test/java/org/thingsboard/server/transport/lwm2m/AbstractLwM2MIntegrationTest.java
  2. 6
      application/src/test/java/org/thingsboard/server/transport/lwm2m/client/LwM2MTestClient.java
  3. 6
      application/src/test/java/org/thingsboard/server/transport/lwm2m/ota/sql/OtaLwM2MIntegrationTest.java
  4. 2
      application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/AbstractRpcLwM2MIntegrationTest.java

7
application/src/test/java/org/thingsboard/server/transport/lwm2m/AbstractLwM2MIntegrationTest.java

@ -186,7 +186,7 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractWebsocketTest
wsClient.registerWaitForUpdate();
this.endpoint = endpoint;
createNewClient (security, coapConfig);
createNewClient (security, coapConfig, false);
String msg = wsClient.waitForUpdate();
EntityDataUpdate update = mapper.readValue(msg, EntityDataUpdate.class);
@ -256,12 +256,11 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractWebsocketTest
this.endpoint = endpoint;
}
public void createNewClient (Security security, NetworkConfig coapConfig) throws Exception {
public void createNewClient (Security security, NetworkConfig coapConfig, boolean isRpc) throws Exception {
clientDestroy();
client = new LwM2MTestClient(this.executor, this.endpoint);
int clientPort = SocketUtils.findAvailableTcpPort();
client.init(security, coapConfig, clientPort);
client.start();
client.init(security, coapConfig, clientPort, isRpc);
}
private void clientDestroy() {

6
application/src/test/java/org/thingsboard/server/transport/lwm2m/client/LwM2MTestClient.java

@ -46,7 +46,6 @@ import org.eclipse.leshan.core.request.RegisterRequest;
import org.eclipse.leshan.core.request.UpdateRequest;
import org.thingsboard.server.transport.lwm2m.utils.LwM2mValueConverterImpl;
import org.junit.Assert;
import org.junit.Assert;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -85,7 +84,7 @@ public class LwM2MTestClient {
private LwM2MLocationParams locationParams;
private LwM2mTemperatureSensor lwM2MTemperatureSensor;
public void init(Security security, NetworkConfig coapConfig, int port) throws InvalidDDFFileException, IOException {
public void init(Security security, NetworkConfig coapConfig, int port, boolean isRpc) throws InvalidDDFFileException, IOException {
Assert.assertNull("client already initialized", client);
List<ObjectModel> models = new ArrayList<>();
for (String resourceName : resources) {
@ -250,6 +249,9 @@ public class LwM2MTestClient {
}
};
this.client.addObserver(observer);
if (!isRpc) {
client.start();
}
}
public void destroy() {

6
application/src/test/java/org/thingsboard/server/transport/lwm2m/ota/sql/OtaLwM2MIntegrationTest.java

@ -137,7 +137,7 @@ public class OtaLwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest {
createDeviceProfile(transportConfiguration);
NoSecClientCredentials credentials = createNoSecClientCredentials(endpoint);
final Device device = createDevice(credentials);
createNewClient(SECURITY, COAP_CONFIG);
createNewClient(SECURITY, COAP_CONFIG, false);
Thread.sleep(1000);
@ -164,7 +164,7 @@ public class OtaLwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest {
createDeviceProfile(OTA_TRANSPORT_CONFIGURATION);
NoSecClientCredentials credentials = createNoSecClientCredentials(endpoint);
final Device device = createDevice(credentials);
createNewClient(SECURITY, COAP_CONFIG);
createNewClient(SECURITY, COAP_CONFIG, false);
Thread.sleep(1000);
@ -203,7 +203,7 @@ public class OtaLwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest {
createDeviceProfile(OTA_TRANSPORT_CONFIGURATION);
NoSecClientCredentials credentials = createNoSecClientCredentials(endpoint);
final Device device = createDevice(credentials);
createNewClient(SECURITY, COAP_CONFIG);
createNewClient(SECURITY, COAP_CONFIG, false);
Thread.sleep(1000);

2
application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/AbstractRpcLwM2MIntegrationTest.java

@ -81,7 +81,7 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
@Before
public void beforeTest() throws Exception {
init();
createNewClient (SECURITY, COAP_CONFIG);
createNewClient (SECURITY, COAP_CONFIG, true);
Thread.sleep(1000);

Loading…
Cancel
Save