Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
WIP k3po http/1.1
  • Loading branch information
attilakreiner committed Jan 18, 2024
commit 3aef60013c52c21473f8c9437af5fccf7b0d6abf
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,19 @@ public class ValidationIT
@Test
@Configuration("client.validation.yaml")
@Specification({
"${app}/invalid.response/client",
"${net}/invalid.response/server" })
public void shouldRejectInvalidRequests() throws Exception
"${app}/invalid.response.header/client",
"${net}/invalid.response.header/server" })
public void shouldSendErrorForInvalidHeaderResponse() throws Exception
{
k3po.finish();
}

@Test
@Configuration("client.validation.yaml")
@Specification({
"${app}/invalid.response.content/client",
"${net}/invalid.response.content/server" })
public void shouldAbortForInvalidContentResponse() throws Exception
{
k3po.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ bindings:
- status: 200
content-type:
- text/plain
headers:
x-hello: test
content: test
versions:
- http/1.1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# 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.
#

connect "zilla://streams/app0"
option zilla:window 8192
option zilla:transmission "half-duplex"

write zilla:begin.ext ${http:beginEx()
.typeId(zilla:id("http"))
.header(":scheme", "http")
.header(":method", "GET")
.header(":path", "/hello")
.header(":authority", "localhost:8080")
.build()}
connected

write close

read zilla:begin.ext ${http:matchBeginEx()
.typeId(zilla:id("http"))
.header(":status", "503")
.header("retry-after", "0")
.build()}

read closed
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.
#

accept "zilla://streams/app0"
option zilla:window 8192
option zilla:transmission "half-duplex"
accepted

read zilla:begin.ext ${http:beginEx()
.typeId(zilla:id("http"))
.header(":scheme", "http")
.header(":method", "GET")
.header(":path", "/hello")
.header(":authority", "localhost:8080")
.build()}
connected

read closed

write zilla:begin.ext ${http:beginEx()
.typeId(zilla:id("http"))
.header(":status", "503")
.header("retry-after", "0")
.build()}

write close
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ read zilla:begin.ext ${http:matchBeginEx()
.header(":status", "200")
.header("content-length", "13")
.header("content-type", "text/plain")
.header("x-hello", "1234567890123")
.build()}

read "1234567890123"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ write zilla:begin.ext ${http:beginEx()
.header(":status", "200")
.header("content-length", "13")
.header("content-type", "text/plain")
.header("x-hello", "1234567890123")
.build()}

write "1234567890123"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# 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.
#

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

write "GET /hello HTTP/1.1" "\r\n"
write "Host: localhost:8080" "\r\n"
write "\r\n"

read "HTTP/1.1 200 OK" "\r\n"
read "Content-Length: 7" "\r\n"
read "Content-Type: text/plain" "\r\n"
read "\r\n"
read "invalid"
read closed
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.
#

accept "zilla://streams/net0"
option zilla:window 8192
option zilla:transmission "duplex"
accepted
connected

read "GET /hello HTTP/1.1" "\r\n"
read "Host: localhost:8080" "\r\n"
read "\r\n"

write "HTTP/1.1 200 OK" "\r\n"
write "Content-Length: 7" "\r\n"
write "Content-Type: text/plain" "\r\n"
write "x-hello: invalid" "\r\n"
write "\r\n"
write "invalid"
write close
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ read "\r\n"
write "HTTP/1.1 200 OK" "\r\n"
write "Content-Length: 13" "\r\n"
write "Content-Type: text/plain" "\r\n"
write "x-hello: 1234567890123" "\r\n"
write "\r\n"
write "1234567890123"
write close
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,18 @@ public void shouldProcessValidRequests() throws Exception

@Test
@Specification({
"${app}/invalid.response/client",
"${app}/invalid.response/server" })
public void shouldAbortForInvalidResponse() throws Exception
"${app}/invalid.response.header/client",
"${app}/invalid.response.header/server" })
public void shouldSendErrorForInvalidHeaderResponse() throws Exception
{
k3po.finish();
}

@Test
@Specification({
"${app}/invalid.response.content/client",
"${app}/invalid.response.content/server" })
public void shouldAbortForInvalidContentResponse() throws Exception
{
k3po.finish();
}
Expand Down