summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Geiser <erik.geiser@redteam-pentesting.de>2022-05-12 14:50:47 +0200
committerErik Geiser <erik.geiser@redteam-pentesting.de>2022-05-12 14:50:47 +0200
commitb437b69f18fd2a2e59bd3ff51685896ee53d0709 (patch)
tree8f14972cdfd18e1a9f69f4530a8c7cced6cc5a53
parent1ca156eafb9f20f7884eddc2cf610bade5dfb560 (diff)
Add failing test case
Signed-off-by: Erik Geiser <erik.geiser@redteam-pentesting.de>
-rw-r--r--rfc1035label/label_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/rfc1035label/label_test.go b/rfc1035label/label_test.go
index 6098e44..2e20736 100644
--- a/rfc1035label/label_test.go
+++ b/rfc1035label/label_test.go
@@ -28,6 +28,18 @@ func TestLabelsFromBytesZeroLength(t *testing.T) {
require.Equal(t, []byte{}, labels.ToBytes())
}
+func TestLabelsFromBytesWithoutZeroLength(t *testing.T) {
+ expected := []byte{
+ 0x8, 'h', 'o', 's', 't', 'n', 'a', 'm', 'e',
+ }
+ labels, err := FromBytes(expected)
+ require.NoError(t, err)
+ require.Equal(t, 1, len(labels.Labels))
+ require.Equal(t, len(expected), labels.Length())
+ require.Equal(t, expected, labels.ToBytes())
+ require.Equal(t, "hostname", labels.Labels[0])
+}
+
func TestLabelsFromBytesInvalidLength(t *testing.T) {
_, err := FromBytes([]byte{0x5, 0xaa, 0xbb}) // short length
require.Error(t, err)