Skip to content

Commit

Permalink
Merge branch 'master' into load-test-results
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK authored Mar 5, 2024
2 parents e6f01ff + 17582e8 commit 0957f00
Show file tree
Hide file tree
Showing 29 changed files with 216 additions and 66 deletions.
6 changes: 3 additions & 3 deletions ballerina-tests/http-advanced-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
org = "ballerina"
name = "http_advanced_tests"
version = "2.10.7"
version = "2.10.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.10.7"
version = "2.10.8"

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.10.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.10.8.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-advanced-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -105,7 +105,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_advanced_tests"
version = "2.10.7"
version = "2.10.8"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "file"},
Expand All @@ -125,7 +125,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-client-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
org = "ballerina"
name = "http_client_tests"
version = "2.10.7"
version = "2.10.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.10.7"
version = "2.10.8"

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.10.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.10.8.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-client-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -102,7 +102,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_client_tests"
version = "2.10.7"
version = "2.10.8"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "http"},
Expand All @@ -121,7 +121,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. 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.

import ballerina/http;
import ballerina/test;

final http:Client http2ClientHost1 = check new("localhost:" + http2ClientHostHeaderTestPort.toString());
final http:Client http2ClientHost2 = check new("localhost:" + httpClientHostHeaderTestPort.toString());
final http:Client httpClientHost1 = check new("localhost:" + httpClientHostHeaderTestPort.toString(), httpVersion = http:HTTP_1_1);
final http:Client httpClientHost2 = check new("localhost:" + http2ClientHostHeaderTestPort.toString(), httpVersion = http:HTTP_1_1);

service / on new http:Listener(http2ClientHostHeaderTestPort) {

resource function 'default host(http:Request req) returns string|error {
return req.getHeader("Host");
}
}

service / on new http:Listener(httpClientHostHeaderTestPort, httpVersion = http:HTTP_1_1) {

resource function 'default host(http:Request req) returns string|error {
return req.getHeader("Host");
}
}

@test:Config {}
function testHttpClientHostHeader1() returns error? {
string host = check httpClientHost1->/host;
test:assertEquals(host, "localhost:" + httpClientHostHeaderTestPort.toString());

host = check httpClientHost1->get("/host");
test:assertEquals(host, "localhost:" + httpClientHostHeaderTestPort.toString());

host = check httpClientHost2->/host;
test:assertEquals(host, "localhost:" + http2ClientHostHeaderTestPort.toString());

host = check httpClientHost2->get("/host");
test:assertEquals(host, "localhost:" + http2ClientHostHeaderTestPort.toString());
}

@test:Config {}
function testHttpClientHostHeader2() returns error? {
string host = check httpClientHost1->/host.get({"Host": "mock.com"});
test:assertEquals(host, "mock.com");

host = check httpClientHost1->get("/host", {"Host": "mock.com"});
test:assertEquals(host, "mock.com");

host = check httpClientHost2->/host.get({"Host": "mock.com"});
test:assertEquals(host, "mock.com");

host = check httpClientHost2->get("/host", {"Host": "mock.com"});
test:assertEquals(host, "mock.com");
}

@test:Config {}
function testHttpClientHostHeader3() returns error? {
http:Request req = new;
req.setHeader("Host", "mock.com");
string host = check httpClientHost1->/host.post(req);
test:assertEquals(host, "mock.com");

host = check httpClientHost1->post("/host", req, {"Host": "mock2.com"});
test:assertEquals(host, "mock2.com");

host = check httpClientHost2->/host.post(req);
test:assertEquals(host, "mock2.com");

host = check httpClientHost2->post("/host", req, {"Host": "mock3.com"});
test:assertEquals(host, "mock3.com");
}

@test:Config {}
function testHttp2ClientHostHeader1() returns error? {
string host = check http2ClientHost1->/host;
test:assertEquals(host, "localhost:" + http2ClientHostHeaderTestPort.toString());

host = check http2ClientHost1->get("/host");
test:assertEquals(host, "localhost:" + http2ClientHostHeaderTestPort.toString());

host = check http2ClientHost2->/host;
test:assertEquals(host, "localhost:" + httpClientHostHeaderTestPort.toString());

host = check http2ClientHost2->get("/host");
test:assertEquals(host, "localhost:" + httpClientHostHeaderTestPort.toString());
}

@test:Config {}
function testHttp2ClientHostHeader2() returns error? {
string host = check http2ClientHost1->/host.get({"Host": "mock.com"});
test:assertEquals(host, "mock.com");

host = check http2ClientHost1->get("/host", {"Host": "mock.com"});
test:assertEquals(host, "mock.com");

host = check http2ClientHost2->/host.get({"Host": "mock.com"});
test:assertEquals(host, "mock.com");

host = check http2ClientHost2->get("/host", {"Host": "mock.com"});
test:assertEquals(host, "mock.com");
}

@test:Config {}
function testHttp2ClientHostHeader3() returns error? {
http:Request req = new;
req.setHeader("Host", "mock.com");
string host = check http2ClientHost1->/host.post(req);
test:assertEquals(host, "mock.com");

host = check http2ClientHost1->post("/host", req, {"Host": "mock2.com"});
test:assertEquals(host, "mock2.com");

host = check http2ClientHost2->/host.post(req);
test:assertEquals(host, "mock2.com");

host = check http2ClientHost2->post("/host", req, {"Host": "mock3.com"});
test:assertEquals(host, "mock3.com");
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ const int clientSchemeTestHttpsListenerTestPort = 9624;

const int clientResourceMethodsTestPort = 9631;
const int clientFormUrlEncodedTestPort = 9604;

const int http2ClientHostHeaderTestPort = 9605;
const int httpClientHostHeaderTestPort = 9606;
6 changes: 3 additions & 3 deletions ballerina-tests/http-dispatching-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
org = "ballerina"
name = "http_dispatching_tests"
version = "2.10.7"
version = "2.10.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.10.7"
version = "2.10.8"

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.10.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.10.8.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-dispatching-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -102,7 +102,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_dispatching_tests"
version = "2.10.7"
version = "2.10.8"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "http"},
Expand All @@ -124,7 +124,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-interceptor-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
org = "ballerina"
name = "http_interceptor_tests"
version = "2.10.7"
version = "2.10.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.10.7"
version = "2.10.8"

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.10.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.10.8.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-interceptor-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -99,7 +99,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_interceptor_tests"
version = "2.10.7"
version = "2.10.8"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "http_test_common"},
Expand All @@ -115,7 +115,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-misc-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
org = "ballerina"
name = "http_misc_tests"
version = "2.10.7"
version = "2.10.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.10.7"
version = "2.10.8"

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.10.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.10.8.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-misc-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -99,7 +99,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_misc_tests"
version = "2.10.7"
version = "2.10.8"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "http_test_common"},
Expand All @@ -118,7 +118,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.10.7"
version = "2.10.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-resiliency-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
org = "ballerina"
name = "http_resiliency_tests"
version = "2.10.7"
version = "2.10.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.10.7"
version = "2.10.8"

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.10.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.10.8.jar"
Loading

0 comments on commit 0957f00

Please sign in to comment.