Skip to content

Commit

Permalink
Modify existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HindujaB committed May 2, 2024
1 parent bf30ec2 commit 653e601
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ballerina-tests/artifacts-tests/tests/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ testPort = 9090

[ballerinax.wso2.controlplane]
keyStorePath = "../resources/certsandkeys/ballerinaKeystore.p12"
trustStorePath = "../resources/certsandkeys/ballerinaTruststore.p12"
icpServicePort = 9165

[ballerinax.wso2.controlplane.dashboard]
Expand All @@ -11,3 +12,5 @@ heartbeatInterval = 5
groupId = "bal_dev"
nodeId = "dev_node_3"
mgtApiUrl ="https://localhost:9165/management/"
serviceAccount = "admin"
serviceAccountPassword = "admin"
33 changes: 30 additions & 3 deletions ballerina-tests/artifacts-tests/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,45 @@ import ballerinax/wso2.controlplane as cp;

configurable string testURL = ?;
configurable int testPort = ?;
string token = "";

@test:BeforeSuite
function registerClient() returns error? {
http:Client icpClient = check new (testURL,
auth = {
username: "admin",
password: "admin"
},
secureSocket = {
enable: false
}
);
record {
string AccessToken;
} result = check icpClient->/management/login();
token = result.AccessToken;
}

@test:Config {}
public function testGetBallerinaNode() returns error? {
http:Client icpClient = check new (testURL,
http:Client mngClient = check new (testURL,
auth = {
token: token
},
secureSocket = {
enable: false
}
);
cp:Node|error node = icpClient->/management();
cp:Node|error node = mngClient->/management();
test:assertTrue(node is cp:Node, "Invalid response received");
}

@test:Config {}
public function testGetBallerinaServiceArtifacts() returns error? {
http:Client rmClient = check new (testURL,
auth = {
token: token
},
secureSocket = {
enable: false
}
Expand All @@ -52,6 +76,9 @@ public function testGetBallerinaListenerArtifacts() returns error? {
http:Client rmClient = check new (testURL,
secureSocket = {
enable: false
},
auth = {
token: token
}
);
cp:Artifacts|error artifacts = rmClient->/management/listeners();
Expand All @@ -68,7 +95,7 @@ service /hello on new http:Listener(testPort) {
return "Hello, World!";
}

resource function get albums/[string title]/[string user]/[string ...]() returns string|http:NotFound {
resource function get albums/[string title]/[string user]/[string...]() returns string|http:NotFound {
return "Hello, World!";
}
}

0 comments on commit 653e601

Please sign in to comment.