-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
451 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tests/jballerina-integration-test/src/test/resources/http/src/cookie/cookieClient_07.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2020 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 Inc. 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/io; | ||
import ballerina/file; | ||
|
||
public function main() { | ||
http:CsvPersistentCookieHandler myPersistentStore = new("./cookie-test-data/client-7.csv"); | ||
http:Client cookieClientEndpoint = new ("http://localhost:9253", { | ||
cookieConfig: { enabled: true, persistentCookieHandler: myPersistentStore } | ||
}); | ||
http:Request req = new; | ||
// Server sends the cookies in the response for the first request. | ||
var response = cookieClientEndpoint->get("/cookie/cookieBackend_1", req); | ||
// Removes a persistent cookie. | ||
http:CookieStore? myCookieStore = cookieClientEndpoint.getCookieStore(); | ||
if (myCookieStore is http:CookieStore) { | ||
var removeResult = myCookieStore.removeCookie("SID001", "localhost:9253", "/cookie/cookieBackend_1"); | ||
if (removeResult is error) { | ||
io:println(removeResult); | ||
} | ||
} | ||
// Sends a request again after one persistent cookie is removed. | ||
response = cookieClientEndpoint->get("/cookie/cookieBackend_1", req); | ||
if (response is http:Response) { | ||
var payload = response.getTextPayload(); | ||
if (payload is string) { | ||
io:print(payload); | ||
} | ||
} | ||
error? removeResults = file:remove("./cookie-test-data", true); | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/jballerina-integration-test/src/test/resources/http/src/cookie/cookieClient_08.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2020 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 Inc. 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/io; | ||
import ballerina/file; | ||
|
||
public function main() { | ||
http:CsvPersistentCookieHandler myPersistentStore = new("./cookie-test-data/client-8.csv"); | ||
http:Client cookieClientEndpoint = new ("http://localhost:9253", { | ||
cookieConfig: { enabled: true, persistentCookieHandler: myPersistentStore } | ||
}); | ||
http:Request req = new; | ||
// Server sends similar persistent cookies in the response for the first request. | ||
var response = cookieClientEndpoint->get("/cookie/cookieBackend_4", req); | ||
// Sends second request after replacing the old cookie with the new. | ||
response = cookieClientEndpoint->get("/cookie/cookieBackend_4", req); | ||
if (response is http:Response) { | ||
var payload = response.getTextPayload(); | ||
if (payload is string) { | ||
io:print(payload); | ||
} | ||
} | ||
error? removeResults = file:remove("./cookie-test-data", true); | ||
} |
Oops, something went wrong.