Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public final class MqttServerFactory implements MqttStreamFactory
private static final String16FW MQTT_PROTOCOL_NAME = new String16FW("MQTT", BIG_ENDIAN);
public static final int MQTT_PROTOCOL_VERSION_5 = 5;
public static final int MQTT_PROTOCOL_VERSION_4 = 4;
private static final int MAXIMUM_CLIENT_ID_LENGTH = 36;
private static final int MAXIMUM_CLIENT_ID_LENGTH = 256;
private static final int CONNECT_FIXED_HEADER = 0b0001_0000;
private static final int SUBSCRIBE_FIXED_HEADER = 0b1000_0010;
private static final int UNSUBSCRIBE_FIXED_HEADER = 0b1010_0010;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ public void shouldRejectMissingClientId() throws Exception
k3po.finish();
}

@Test
@Configuration("server.yaml")
@Specification({
"${net}/connect.reject.exceeding.max.client.id/client"})
public void shouldRejectExceedingClientIdMax() throws Exception
{
k3po.finish();
}

@Test
@Configuration("server.yaml")
@Specification({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ public void shouldRejectMissingClientId() throws Exception
k3po.finish();
}

@Test
@Configuration("server.yaml")
@Specification({
"${net}/connect.reject.exceeding.max.client.id/client"})
public void shouldRejectExceedingClientIdMax() throws Exception
{
k3po.finish();
}

@Test
@Configuration("server.yaml")
@Specification({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright 2021-2023 Aklivity Inc.
#
# Aklivity licenses this file to you 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.
#

property clientId "gnybrelierkwcjyozqfhuitsibaetvbphfoewzaongylsrluxbcwjtgqkixfcdxvgyerkjifnzsflkbgumlzbgrqjgjnjkpxsfntbewlsjliookwmbwucllvvnuychrnyvktsxdwmggsljcljzomkxyiquzjsljtdgfbbnsntxghgbjjfedtruedlqkzmoxnapgmxqlafwzgrxuqscznhlvzdlxhkezkmthwobmppnzjecbbodtsdzvxwlkyfpvwq"

connect "zilla://streams/net0"
option zilla:window 8192
option zilla:transmission "duplex"
option zilla:byteorder "network"

connected

write [0x10 0x8d 0x02] # CONNECT
[0x00 0x04] "MQTT" # protocol name
[0x04] # protocol version
[0x02] # flags = clean start
[0x00 0x3c] # keep alive = 60s
[0x01 0x01] ${clientId} # client id

read closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright 2021-2023 Aklivity Inc.
#
# Aklivity licenses this file to you 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.
#

property clientId "gnybrelierkwcjyozqfhuitsibaetvbphfoewzaongylsrluxbcwjtgqkixfcdxvgyerkjifnzsflkbgumlzbgrqjgjnjkpxsfntbewlsjliookwmbwucllvvnuychrnyvktsxdwmggsljcljzomkxyiquzjsljtdgfbbnsntxghgbjjfedtruedlqkzmoxnapgmxqlafwzgrxuqscznhlvzdlxhkezkmthwobmppnzjecbbodtsdzvxwlkyfpvwq"

accept "zilla://streams/net0"
option zilla:window 8192
option zilla:transmission "duplex"
option zilla:byteorder "network"

accepted
connected

read [0x10 0x8d 0x02] # CONNECT
[0x00 0x04] "MQTT" # protocol name
[0x04] # protocol version
[0x02] # flags = clean start
[0x00 0x3c] # keep alive = 60s
[0x01 0x01] ${clientId} # client id

write close
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright 2021-2023 Aklivity Inc.
#
# Aklivity licenses this file to you 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.
#

property clientId "gnybrelierkwcjyozqfhuitsibaetvbphfoewzaongylsrluxbcwjtgqkixfcdxvgyerkjifnzsflkbgumlzbgrqjgjnjkpxsfntbewlsjliookwmbwucllvvnuychrnyvktsxdwmggsljcljzomkxyiquzjsljtdgfbbnsntxghgbjjfedtruedlqkzmoxnapgmxqlafwzgrxuqscznhlvzdlxhkezkmthwobmppnzjecbbodtsdzvxwlkyfpvwq"

connect "zilla://streams/net0"
option zilla:window 8192
option zilla:transmission "duplex"
option zilla:byteorder "network"

connected

write [0x10 0x8e 0x02] # CONNECT
[0x00 0x04] "MQTT" # protocol name
[0x05] # protocol version
[0x02] # flags = clean start
[0x00 0x3c] # keep alive = 60s
[0x00] # properties = none
[0x01 0x01] ${clientId} # client id

read [0x20 0x03] # CONNACK
[0x00] # flags = none
[0x85] # reason = Client Identifier not valid
[0x00] # properties = none

read closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright 2021-2023 Aklivity Inc.
#
# Aklivity licenses this file to you 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.
#

property clientId "gnybrelierkwcjyozqfhuitsibaetvbphfoewzaongylsrluxbcwjtgqkixfcdxvgyerkjifnzsflkbgumlzbgrqjgjnjkpxsfntbewlsjliookwmbwucllvvnuychrnyvktsxdwmggsljcljzomkxyiquzjsljtdgfbbnsntxghgbjjfedtruedlqkzmoxnapgmxqlafwzgrxuqscznhlvzdlxhkezkmthwobmppnzjecbbodtsdzvxwlkyfpvwq"

accept "zilla://streams/net0"
option zilla:window 8192
option zilla:transmission "duplex"
option zilla:byteorder "network"

accepted
connected

read [0x10 0x8e 0x02] # CONNECT
[0x00 0x04] "MQTT" # protocol name
[0x05] # protocol version
[0x02] # flags = clean start
[0x00 0x3c] # keep alive = 60s
[0x00] # properties = none
[0x01 0x01] ${clientId} # client id

write [0x20 0x03] # CONNACK
[0x00] # flags = none
[0x85] # reason = Client Identifier not valid
[0x00] # properties = none

write close
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ public void shouldRejectMissingClientId() throws Exception
k3po.finish();
}

@Test
@Specification({
"${net}/connect.reject.exceeding.max.client.id/client",
"${net}/connect.reject.exceeding.max.client.id/server"})
public void shouldRejectExceedingClientIdMax() throws Exception
{
k3po.finish();
}

@Test
@Specification({
"${net}/connect.reject.no.client.id.no.clean.session/client",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ public void shouldRejectMissingClientId() throws Exception
k3po.finish();
}

@Test
@Specification({
"${net}/connect.reject.exceeding.max.client.id/client",
"${net}/connect.reject.exceeding.max.client.id/server"})
public void shouldRejectExceedingClientIdMax() throws Exception
{
k3po.finish();
}

@Test
@Specification({
"${net}/disconnect/client",
Expand Down