23 changed files with 707 additions and 43 deletions
@ -0,0 +1,81 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.client; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.eclipse.californium.scandium.dtls.ClientHandshaker; |
||||
|
import org.eclipse.californium.scandium.dtls.DTLSContext; |
||||
|
import org.eclipse.californium.scandium.dtls.HandshakeException; |
||||
|
import org.eclipse.californium.scandium.dtls.Handshaker; |
||||
|
import org.eclipse.californium.scandium.dtls.SessionAdapter; |
||||
|
import org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_READ_CONNECTION_ID; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_WRITE_CONNECTION_ID; |
||||
|
|
||||
|
@Slf4j |
||||
|
public class DtlsSessionLogger extends SessionAdapter { |
||||
|
|
||||
|
private final Set<LwM2MClientState> clientStates; |
||||
|
private final Map<LwM2MClientState, Integer> clientDtlsCid; |
||||
|
|
||||
|
public DtlsSessionLogger(Set<LwM2MClientState> clientStates, Map<LwM2MClientState, Integer> clientDtlsCid) { |
||||
|
this.clientStates = clientStates; |
||||
|
this.clientDtlsCid = clientDtlsCid; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void handshakeStarted(Handshaker handshaker) throws HandshakeException { |
||||
|
if (handshaker instanceof ClientHandshaker) { |
||||
|
log.info("DTLS Full Handshake initiated by client : STARTED ..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void contextEstablished(Handshaker handshaker, DTLSContext establishedContext) throws HandshakeException { |
||||
|
if (handshaker instanceof ClientHandshaker) { |
||||
|
log.warn("DTLS initiated by client: SUCCEED, WriteConnectionId: [{}], ReadConnectionId: [{}]", establishedContext.getWriteConnectionId(), establishedContext.getReadConnectionId()); |
||||
|
clientStates.add(ON_WRITE_CONNECTION_ID); |
||||
|
clientStates.add(ON_READ_CONNECTION_ID); |
||||
|
Integer lenWrite = establishedContext.getWriteConnectionId() == null ? null : establishedContext.getWriteConnectionId().getBytes().length; |
||||
|
Integer lenRead = establishedContext.getReadConnectionId() == null ? null : establishedContext.getReadConnectionId().getBytes().length; |
||||
|
clientDtlsCid.put(ON_WRITE_CONNECTION_ID, lenWrite); |
||||
|
clientDtlsCid.put(ON_READ_CONNECTION_ID, lenRead); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void handshakeFailed(Handshaker handshaker, Throwable error) { |
||||
|
// get cause
|
||||
|
String cause; |
||||
|
if (error != null) { |
||||
|
if (error.getMessage() != null) { |
||||
|
cause = error.getMessage(); |
||||
|
} else { |
||||
|
cause = error.getClass().getName(); |
||||
|
} |
||||
|
} else { |
||||
|
cause = "unknown cause"; |
||||
|
} |
||||
|
|
||||
|
if (handshaker instanceof ClientHandshaker) { |
||||
|
log.info("DTLS Full Handshake initiated by client : FAILED ({})", cause); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.test.context.TestPropertySource; |
||||
|
import org.thingsboard.server.dao.service.DaoSqlTest; |
||||
|
|
||||
|
|
||||
|
@TestPropertySource(properties = { |
||||
|
"transport.lwm2m.dtls.connection_id_length=0" |
||||
|
}) |
||||
|
|
||||
|
@DaoSqlTest |
||||
|
@Slf4j |
||||
|
public abstract class AbstractSecurityLwM2MIntegrationDtlsCidLength0Test extends AbstractSecurityLwM2MIntegrationDtlsCidLengthTest { |
||||
|
|
||||
|
|
||||
|
protected void testNoSecDtlsCidLength(Integer dtlsCidLength) throws Exception { |
||||
|
testNoSecDtlsCidLength(dtlsCidLength, 0); |
||||
|
} |
||||
|
protected void testPskDtlsCidLength(Integer dtlsCidLength) throws Exception { |
||||
|
testPskDtlsCidLength(dtlsCidLength, 0); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.test.context.TestPropertySource; |
||||
|
import org.thingsboard.server.dao.service.DaoSqlTest; |
||||
|
|
||||
|
|
||||
|
@TestPropertySource(properties = { |
||||
|
"transport.lwm2m.dtls.connection_id_length=3" |
||||
|
}) |
||||
|
|
||||
|
@DaoSqlTest |
||||
|
@Slf4j |
||||
|
public abstract class AbstractSecurityLwM2MIntegrationDtlsCidLength3Test extends AbstractSecurityLwM2MIntegrationDtlsCidLengthTest { |
||||
|
|
||||
|
protected void testNoSecDtlsCidLength(Integer dtlsCidLength) throws Exception { |
||||
|
testNoSecDtlsCidLength(dtlsCidLength, 3); |
||||
|
} |
||||
|
protected void testPskDtlsCidLength(Integer dtlsCidLength) throws Exception { |
||||
|
testPskDtlsCidLength(dtlsCidLength, 3); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.test.context.TestPropertySource; |
||||
|
import org.thingsboard.server.dao.service.DaoSqlTest; |
||||
|
|
||||
|
|
||||
|
@TestPropertySource(properties = { |
||||
|
"transport.lwm2m.dtls.connection_id_length=" |
||||
|
}) |
||||
|
|
||||
|
@DaoSqlTest |
||||
|
@Slf4j |
||||
|
public abstract class AbstractSecurityLwM2MIntegrationDtlsCidLengthNullTest extends AbstractSecurityLwM2MIntegrationDtlsCidLengthTest { |
||||
|
|
||||
|
|
||||
|
protected void testNoSecDtlsCidLength(Integer dtlsCidLength) throws Exception { |
||||
|
testNoSecDtlsCidLength(dtlsCidLength, null); |
||||
|
} |
||||
|
protected void testPskDtlsCidLength(Integer dtlsCidLength) throws Exception { |
||||
|
testPskDtlsCidLength(dtlsCidLength, null); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,133 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.eclipse.californium.elements.config.Configuration; |
||||
|
import org.eclipse.leshan.client.californium.endpoint.CaliforniumClientEndpoint; |
||||
|
import org.eclipse.leshan.client.californium.endpoint.CaliforniumClientEndpointsProvider; |
||||
|
import org.eclipse.leshan.client.object.Security; |
||||
|
import org.eclipse.leshan.core.util.Hex; |
||||
|
import org.junit.Assert; |
||||
|
import org.thingsboard.server.common.data.Device; |
||||
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.AbstractLwM2MClientSecurityCredential; |
||||
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MDeviceCredentials; |
||||
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; |
||||
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.PSKClientCredential; |
||||
|
import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration; |
||||
|
import org.thingsboard.server.dao.service.DaoSqlTest; |
||||
|
import org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState; |
||||
|
import org.thingsboard.server.transport.lwm2m.security.AbstractSecurityLwM2MIntegrationTest; |
||||
|
|
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.HashSet; |
||||
|
import java.util.Random; |
||||
|
import java.util.Set; |
||||
|
import java.util.concurrent.TimeUnit; |
||||
|
|
||||
|
import static org.awaitility.Awaitility.await; |
||||
|
import static org.eclipse.californium.scandium.config.DtlsConfig.DTLS_CONNECTION_ID_LENGTH; |
||||
|
import static org.eclipse.leshan.client.object.Security.psk; |
||||
|
import static org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode.PSK; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_INIT; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_READ_CONNECTION_ID; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_REGISTRATION_STARTED; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_REGISTRATION_SUCCESS; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_UPDATE_SUCCESS; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MClientState.ON_WRITE_CONNECTION_ID; |
||||
|
|
||||
|
@DaoSqlTest |
||||
|
@Slf4j |
||||
|
public abstract class AbstractSecurityLwM2MIntegrationDtlsCidLengthTest extends AbstractSecurityLwM2MIntegrationTest { |
||||
|
|
||||
|
protected AbstractLwM2MClientSecurityCredential clientCredentials; |
||||
|
protected Security security; |
||||
|
protected Lwm2mDeviceProfileTransportConfiguration transportConfiguration; |
||||
|
protected LwM2MDeviceCredentials deviceCredentials; |
||||
|
protected String clientEndpoint; |
||||
|
protected LwM2MSecurityMode lwM2MSecurityMode; |
||||
|
protected String awaitAlias; |
||||
|
protected final Random randomSuffix = new Random(); |
||||
|
|
||||
|
protected final Set<LwM2MClientState> expectedStatusesRegistrationLwm2mDtlsCidSuccess = new HashSet<>(Arrays.asList(ON_INIT, ON_REGISTRATION_STARTED, ON_REGISTRATION_SUCCESS, ON_READ_CONNECTION_ID, ON_WRITE_CONNECTION_ID)); |
||||
|
|
||||
|
|
||||
|
protected void testNoSecDtlsCidLength(Integer dtlsCidLength, Integer serverDtlsCidLength) throws Exception { |
||||
|
initDeviceCredentialsNoSek(); |
||||
|
basicTestConnectionDtlsCidLength(dtlsCidLength, serverDtlsCidLength); |
||||
|
} |
||||
|
protected void testPskDtlsCidLength(Integer dtlsCidLength, Integer serverDtlsCidLength) throws Exception { |
||||
|
initDeviceCredentialsPsk(); |
||||
|
basicTestConnectionDtlsCidLength(dtlsCidLength, serverDtlsCidLength); |
||||
|
} |
||||
|
|
||||
|
protected void initDeviceCredentialsNoSek() { |
||||
|
clientEndpoint = CLIENT_ENDPOINT_NO_SEC + "_" + randomSuffix.nextInt(100); |
||||
|
deviceCredentials = getDeviceCredentialsNoSec(createNoSecClientCredentials(clientEndpoint)); |
||||
|
} |
||||
|
|
||||
|
protected void initDeviceCredentialsPsk() { |
||||
|
int suf = randomSuffix.nextInt(10); |
||||
|
clientEndpoint = CLIENT_ENDPOINT_PSK + "_" + suf; |
||||
|
String identity = CLIENT_PSK_IDENTITY + "_" + suf; |
||||
|
clientCredentials = new PSKClientCredential(); |
||||
|
clientCredentials.setEndpoint(clientEndpoint); |
||||
|
((PSKClientCredential)clientCredentials).setIdentity(identity); |
||||
|
clientCredentials.setKey(CLIENT_PSK_KEY); |
||||
|
security = psk(SECURE_URI, |
||||
|
shortServerId, |
||||
|
identity.getBytes(StandardCharsets.UTF_8), |
||||
|
Hex.decodeHex(CLIENT_PSK_KEY.toCharArray())); |
||||
|
deviceCredentials = getDeviceCredentialsSecure(clientCredentials, null, null, PSK, false); |
||||
|
} |
||||
|
|
||||
|
protected void basicTestConnectionDtlsCidLength(Integer clientDtlsCidLength, |
||||
|
Integer serverDtlsCidLength) throws Exception { |
||||
|
createDeviceProfile(transportConfiguration); |
||||
|
final Device device = createDevice(deviceCredentials, clientEndpoint); |
||||
|
device.getId().getId().toString(); |
||||
|
createNewClient(security, null, COAP_CONFIG, true, clientEndpoint, clientDtlsCidLength); |
||||
|
lwM2MTestClient.start(true); |
||||
|
await(awaitAlias) |
||||
|
.atMost(40, TimeUnit.SECONDS) |
||||
|
.until(() -> lwM2MTestClient.getClientStates().contains(ON_UPDATE_SUCCESS)); |
||||
|
Assert.assertTrue(lwM2MTestClient.getClientStates().containsAll(expectedStatusesRegistrationLwm2mSuccess)); |
||||
|
|
||||
|
Configuration clientCoapConfig = ((CaliforniumClientEndpoint)((CaliforniumClientEndpointsProvider)lwM2MTestClient |
||||
|
.getLeshanClient().getEndpointsProvider().toArray()[0]).getEndpoints().toArray()[0]).getCoapEndpoint().getConfig(); |
||||
|
Assert.assertEquals(clientDtlsCidLength, clientCoapConfig.get(DTLS_CONNECTION_ID_LENGTH)); |
||||
|
|
||||
|
if (security.equals(SECURITY_NO_SEC)) { |
||||
|
Assert.assertTrue(lwM2MTestClient.getClientDtlsCid().isEmpty()); |
||||
|
} else { |
||||
|
Assert.assertEquals(2L, lwM2MTestClient.getClientDtlsCid().size()); |
||||
|
Assert.assertTrue(lwM2MTestClient.getClientDtlsCid().keySet().contains(ON_READ_CONNECTION_ID)); |
||||
|
Assert.assertTrue(lwM2MTestClient.getClientDtlsCid().keySet().contains(ON_WRITE_CONNECTION_ID)); |
||||
|
if (serverDtlsCidLength == null) { |
||||
|
Assert.assertNull(lwM2MTestClient.getClientDtlsCid().get(ON_WRITE_CONNECTION_ID)); |
||||
|
Assert.assertNull(lwM2MTestClient.getClientDtlsCid().get(ON_READ_CONNECTION_ID)); |
||||
|
} else { |
||||
|
Assert.assertEquals(clientDtlsCidLength, lwM2MTestClient.getClientDtlsCid().get(ON_READ_CONNECTION_ID)); |
||||
|
if (clientDtlsCidLength == null) { |
||||
|
Assert.assertNull(lwM2MTestClient.getClientDtlsCid().get(ON_READ_CONNECTION_ID)); |
||||
|
} else { |
||||
|
Assert.assertEquals(Integer.valueOf(serverDtlsCidLength), lwM2MTestClient.getClientDtlsCid().get(ON_WRITE_CONNECTION_ID)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid.serverDtlsCidLength_0; |
||||
|
|
||||
|
import org.junit.Before; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.transport.lwm2m.security.cid.AbstractSecurityLwM2MIntegrationDtlsCidLength0Test; |
||||
|
|
||||
|
import static org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode.NO_SEC; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType.NONE; |
||||
|
|
||||
|
public class NoSecLwM2MIntegrationDtlsCidLengthTest extends AbstractSecurityLwM2MIntegrationDtlsCidLength0Test { |
||||
|
|
||||
|
@Before |
||||
|
public void setUpNoSecDtlsCidLength() { |
||||
|
security = SECURITY_NO_SEC; |
||||
|
transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(NO_SEC, NONE)); |
||||
|
awaitAlias = "await on client state (NoSec_Lwm2m) DtlsCidLength = 0"; |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_Null() throws Exception { |
||||
|
testNoSecDtlsCidLength(null); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_0() throws Exception { |
||||
|
testNoSecDtlsCidLength(0); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_2() throws Exception { |
||||
|
testNoSecDtlsCidLength(2); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid.serverDtlsCidLength_0; |
||||
|
|
||||
|
import org.junit.Before; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.transport.lwm2m.security.cid.AbstractSecurityLwM2MIntegrationDtlsCidLength0Test; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType.NONE; |
||||
|
|
||||
|
public class PskLwm2mIntegrationDtlsCidLengthTest extends AbstractSecurityLwM2MIntegrationDtlsCidLength0Test { |
||||
|
|
||||
|
@Before |
||||
|
public void createProfileRpc() { |
||||
|
transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(lwM2MSecurityMode, NONE)); |
||||
|
awaitAlias = "await on client state (Psk_Lwm2m) DtlsCidLength = 0"; |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_Null() throws Exception { |
||||
|
testPskDtlsCidLength(null); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_0() throws Exception { |
||||
|
testPskDtlsCidLength(0); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_2() throws Exception { |
||||
|
testPskDtlsCidLength(2); |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,48 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid.serverDtlsCidLength_3; |
||||
|
|
||||
|
import org.junit.Before; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.transport.lwm2m.security.cid.AbstractSecurityLwM2MIntegrationDtlsCidLength3Test; |
||||
|
|
||||
|
import static org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode.NO_SEC; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType.NONE; |
||||
|
|
||||
|
public class NoSecLwM2MIntegrationDtlsCidLengthTest extends AbstractSecurityLwM2MIntegrationDtlsCidLength3Test { |
||||
|
|
||||
|
@Before |
||||
|
public void setUpNoSecDtlsCidLength() { |
||||
|
security = SECURITY_NO_SEC; |
||||
|
transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(NO_SEC, NONE)); |
||||
|
awaitAlias = "await on client state (NoSec_Lwm2m) DtlsCidLength = 3"; |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_Null() throws Exception { |
||||
|
testNoSecDtlsCidLength(null); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_0() throws Exception { |
||||
|
testNoSecDtlsCidLength(0); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_2() throws Exception { |
||||
|
testNoSecDtlsCidLength(2); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid.serverDtlsCidLength_3; |
||||
|
|
||||
|
import org.junit.Before; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.transport.lwm2m.security.cid.AbstractSecurityLwM2MIntegrationDtlsCidLength3Test; |
||||
|
|
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType.NONE; |
||||
|
|
||||
|
public class PskLwm2mIntegrationDtlsCidLengthTest extends AbstractSecurityLwM2MIntegrationDtlsCidLength3Test { |
||||
|
|
||||
|
@Before |
||||
|
public void createProfileRpc() { |
||||
|
transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(lwM2MSecurityMode, NONE)); |
||||
|
awaitAlias = "await on client state (Psk_Lwm2m) DtlsCidLength = 3"; |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_Null() throws Exception { |
||||
|
testPskDtlsCidLength(null); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_0() throws Exception { |
||||
|
testPskDtlsCidLength(0); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_2() throws Exception { |
||||
|
testPskDtlsCidLength(2); |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,48 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid.serverDtlsCidLength_null; |
||||
|
|
||||
|
import org.junit.Before; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.transport.lwm2m.security.cid.AbstractSecurityLwM2MIntegrationDtlsCidLengthNullTest; |
||||
|
|
||||
|
import static org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode.NO_SEC; |
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType.NONE; |
||||
|
|
||||
|
public class NoSecLwM2MIntegrationDtlsCidLengthTest extends AbstractSecurityLwM2MIntegrationDtlsCidLengthNullTest { |
||||
|
|
||||
|
@Before |
||||
|
public void setUpNoSecDtlsCidLength() { |
||||
|
security = SECURITY_NO_SEC; |
||||
|
transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(NO_SEC, NONE)); |
||||
|
awaitAlias = "await on client state (NoSec_Lwm2m) DtlsCidLength = Null"; |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_Null() throws Exception { |
||||
|
testNoSecDtlsCidLength(null); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_0() throws Exception { |
||||
|
testNoSecDtlsCidLength(0); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithNoSecConnectLwm2mSuccessClientDtlsCidLength_2() throws Exception { |
||||
|
testNoSecDtlsCidLength(2); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2024 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.transport.lwm2m.security.cid.serverDtlsCidLength_null; |
||||
|
|
||||
|
import org.junit.Before; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.transport.lwm2m.security.cid.AbstractSecurityLwM2MIntegrationDtlsCidLengthNullTest; |
||||
|
|
||||
|
import static org.thingsboard.server.transport.lwm2m.Lwm2mTestHelper.LwM2MProfileBootstrapConfigType.NONE; |
||||
|
|
||||
|
public class PskLwm2mIntegrationDtlsCidLengthTest extends AbstractSecurityLwM2MIntegrationDtlsCidLengthNullTest { |
||||
|
|
||||
|
@Before |
||||
|
public void createProfileRpc() { |
||||
|
transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(lwM2MSecurityMode, NONE)); |
||||
|
awaitAlias = "await on client state (Psk_Lwm2m) DtlsCidLength = Null"; |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_Null() throws Exception { |
||||
|
testPskDtlsCidLength(null); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_0() throws Exception { |
||||
|
testPskDtlsCidLength(0); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testWithPskConnectLwm2mSuccessClientDtlsCidLength_2() throws Exception { |
||||
|
testPskDtlsCidLength(2); |
||||
|
} |
||||
|
} |
||||
|
|
||||
Loading…
Reference in new issue