Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #3

Merged
merged 45 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
277b307
Add support for Microsoft Edge Chromium browser
douglas-six Oct 7, 2020
b256e46
Merge pull request #1302 from sixdouglas/feat/addSupportForMSEdgeChro…
ptrthomas Oct 7, 2020
53eff32
update + docs after #1302 #1303
ptrthomas Oct 7, 2020
09f0a6e
Issue-1076 Updating cucumber-reporting version to 5.3.1
Nishant-sehgal Oct 8, 2020
2125640
Merge pull request #1307 from Nishant-sehgal/develop
ptrthomas Oct 8, 2020
8b50606
Fixing issue that causes karate-config.js from loading an external fi…
joelpramos Oct 8, 2020
faa6005
Issue #1306 Mock Jersey Servlet doesnt add query params to the reques…
Oct 8, 2020
d74ecdb
Merge pull request #1310 from liranz10/liran-hacktoberfest
ptrthomas Oct 9, 2020
0a09ff3
Exposing a method that allows Nashorn to be initiated with a custom c…
joelpramos Oct 9, 2020
fa0fe85
Additional changes for class loader to support packaging as Spring Bo…
joelpramos Oct 10, 2020
6475726
1165 - initial commit
chaudharydeepak Oct 10, 2020
0992955
1165 - initial commit
chaudharydeepak Oct 10, 2020
038802f
Merge pull request #1314 from chaudharydeepak/develop
ptrthomas Oct 10, 2020
cdb10a7
#1211 Standard delete Cookie behaviour does not work in Karate
chaudharydeepak Oct 11, 2020
e252cbf
##1211 Standard delete Cookie behaviour does not work in Karateapplie…
chaudharydeepak Oct 11, 2020
9db1465
Merge pull request #1316 from chaudharydeepak/develop
ptrthomas Oct 11, 2020
8503a2e
Apply changes from rewrite branch onto changes to workaround issues w…
joelpramos Oct 11, 2020
7ebcbfa
Fixing unit test
joelpramos Oct 11, 2020
efb6451
Fixing unit test for CI/CD pipeline
joelpramos Oct 11, 2020
075beaa
Merge pull request #1317 from joelpramos/bugfix/callSingle-in-karate-…
ptrthomas Oct 12, 2020
0cdaa47
refactor over pr #1317
ptrthomas Oct 12, 2020
62c779b
Issue-1175 null error message handling in Result failure
Nishant-sehgal Oct 12, 2020
af20486
Merge pull request #1318 from Nishant-sehgal/develop
ptrthomas Oct 12, 2020
8a4d4a8
Upgrade Spring Boot version in Examples
douglas-six Oct 12, 2020
b7e5bb2
Merge pull request #1323 from sixdouglas/feat/upgradeSpringBootInSamples
ptrthomas Oct 12, 2020
7f70e21
amend username
Oct 13, 2020
ccdc835
do not reset vars in a callonce #1322
ptrthomas Oct 13, 2020
8975d21
Merge branch 'develop' of https://github.com/intuit/karate into develop
ptrthomas Oct 13, 2020
648552e
1293 - pass cookies from UI to api calls
Oct 14, 2020
ab5ce17
1293 - pass cookies from UI to api calls
Oct 14, 2020
90aa9cb
1293 - pass cookies from UI to api calls
Oct 14, 2020
15c1bf8
1293 - pass cookies from UI to api calls - cleanup
Oct 14, 2020
db1c775
1293 - pass cookies from UI to api calls - cleanup
Oct 14, 2020
47b3ed5
#1328 review comments
Oct 14, 2020
2b7be93
Merge pull request #1328 from chaudharydeepak/develop
ptrthomas Oct 15, 2020
758fe9f
improve test to prove #1327 is a duplicate of #1322
ptrthomas Oct 15, 2020
e38be45
1331 - karate-netty proxy sends previous request payload when dealing…
Oct 16, 2020
687ef69
Merge pull request #1332 from chaudharydeepak/develop
ptrthomas Oct 16, 2020
abe0435
1329 - JUnit 5 TestSource
Oct 17, 2020
4878405
1329 - JUnit 5 TestSource review
Oct 17, 2020
bc979e1
Merge pull request #1334 from chaudharydeepak/develop
ptrthomas Oct 17, 2020
e47012c
feat : Bump up Gatling version
douglas-six Oct 17, 2020
c3135cd
Merge pull request #1335 from sixdouglas/feat/bumpUpGatlingVersion
ptrthomas Oct 17, 2020
4084b35
duplicate fix
kruthika16 Oct 17, 2020
7adf16b
Merge pull request #1336 from kruthika16/issue-1292
ptrthomas Oct 18, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target/
.settings
.classpath
.vscode
.java-version
*.iml
build/
bin/
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ Note that this is currently not supported for [JUnit 5](#junit-5) `@Karate.Test

### Command Line - Gradle

For Gradle you must extend the test task to allow the `karate.options` to be passed to the runtime (otherwise they get consumed by Gradle itself). To do that, add the following:
For Gradle, you must extend the test task to allow the `karate.options` to be passed to the runtime (otherwise they get consumed by Gradle itself). To do that, add the following:

```yml
test {
Expand All @@ -585,7 +585,11 @@ test {
And then the above command in Gradle would look like:

```
./gradlew test -Dtest=CatsRunner
./gradlew test --tests *CatsRunner
```
or
```
./gradlew test -Dtest.single=CatsRunner
```

### Test Suites
Expand Down
4 changes: 2 additions & 2 deletions examples/consumer-driven-contracts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<spring.boot.version>2.2.0.RELEASE</spring.boot.version>
<karate.version>0.9.6</karate.version>
<spring.boot.version>2.3.4.RELEASE</spring.boot.version>
<karate.version>2.0.0</karate.version>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion examples/gatling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<karate.version>0.9.6</karate.version>
<karate.version>2.0.0</karate.version>
<gatling.plugin.version>3.0.2</gatling.plugin.version>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion examples/mobile-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<karate.version>0.9.6</karate.version>
<karate.version>2.0.0</karate.version>
</properties>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions examples/mock-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<spring.boot.version>2.2.0.RELEASE</spring.boot.version>
<karate.version>0.9.6</karate.version>
<spring.boot.version>2.3.4.RELEASE</spring.boot.version>
<karate.version>2.0.0</karate.version>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion examples/robot-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<karate.version>0.9.6</karate.version>
<karate.version>2.0.0</karate.version>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion examples/ui-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<karate.version>0.9.6</karate.version>
<karate.version>2.0.0</karate.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,11 @@
import com.intuit.karate.Config;
import com.intuit.karate.FileUtils;
import com.intuit.karate.core.ScenarioContext;
import org.apache.http.conn.ssl.LenientSslConnectionSocketFactory;

import static com.intuit.karate.http.Cookie.*;

import com.intuit.karate.http.HttpClient;
import com.intuit.karate.http.HttpRequest;
import com.intuit.karate.http.HttpResponse;
import com.intuit.karate.http.HttpUtils;
import com.intuit.karate.http.MultiPartItem;
import com.intuit.karate.http.MultiValuedMap;
import java.io.IOException;

import java.io.InputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.nio.charset.Charset;
import java.security.KeyStore;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import javax.net.ssl.SSLContext;

import com.intuit.karate.http.*;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.ParseException;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CookieStore;
Expand All @@ -67,22 +41,28 @@
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.config.SocketConfig;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustAllStrategy;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.conn.ssl.*;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.apache.http.impl.client.*;
import org.apache.http.impl.conn.SystemDefaultRoutePlanner;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;

import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.nio.charset.Charset;
import java.security.KeyStore;
import java.time.ZonedDateTime;
import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.Map.Entry;

import static com.intuit.karate.http.Cookie.*;

/**
* @author pthomas3
*/
Expand Down Expand Up @@ -269,6 +249,21 @@ protected void buildCookie(com.intuit.karate.http.Cookie c) {
case PATH:
cookie.setPath(entry.getValue());
break;
case EXPIRES: // add expires field for cookie.
try {
cookie.setExpiryDate(Date.from(ZonedDateTime.parse(entry.getValue(), DTFMTR_RFC1123).toInstant()));
}
catch ( DateTimeParseException ex)
{
System.err.println("ex ->" + ex.getLocalizedMessage());
}
break;
case MAX_AGE: // set max age
int maxAge = Integer.parseInt(entry.getValue());
if (maxAge >= 0) { // only for valid maxAge for cookie expiration.
cookie.setExpiryDate(new Date(System.currentTimeMillis() + (maxAge * 1000)));
}
break;
}
}
if (cookie.getDomain() == null) {
Expand Down Expand Up @@ -328,8 +323,10 @@ protected HttpResponse makeHttpRequest(HttpEntity entity, ScenarioContext contex
response.setStatus(httpResponse.getStatusLine().getStatusCode());
for (Cookie c : cookieStore.getCookies()) {
com.intuit.karate.http.Cookie cookie = new com.intuit.karate.http.Cookie(c.getName(), c.getValue());
cookie.put(DOMAIN, c.getDomain());
cookie.put(PATH, c.getPath());
// while preparing the cookie in buildCookie method we used a BasicClientCookie. This conversion ensures we get path correctly.
BasicClientCookie cc = (BasicClientCookie) c;
cookie.put(DOMAIN, cc.getDomain());
cookie.put(PATH, cc.getPath());
if (c.getExpiryDate() != null) {
cookie.put(EXPIRES, c.getExpiryDate().getTime() + "");
}
Expand All @@ -338,7 +335,17 @@ protected HttpResponse makeHttpRequest(HttpEntity entity, ScenarioContext contex
response.addCookie(cookie);
}
cookieStore.clear(); // we rely on the StepDefs for cookie 'persistence'
for (Header header : httpResponse.getAllHeaders()) {
for (Header header : httpResponse.getAllHeaders()) { // rely on setting cookies from set-cookie header, else these will be skipped.
if( header.getName().equalsIgnoreCase("Set-Cookie"))
{
List<HttpCookie> cookieMap = HttpCookie.parse(header.getValue());
cookieMap.forEach( ck -> {
com.intuit.karate.http.Cookie cookie = new com.intuit.karate.http.Cookie(ck.getName(), ck.getValue());
cookie.put(DOMAIN, ck.getDomain());
cookie.put(PATH, null != ck.getPath() ? ck.getPath() : "/"); // lets make sure path is not null.
cookie.put(MAX_AGE, ck.getMaxAge() + "");
});
}
response.addHeader(header.getName(), header.getValue());
}
return response;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.intuit.karate.http.apache;

import com.intuit.karate.CallContext;
import com.intuit.karate.Config;
import com.intuit.karate.core.FeatureContext;
import com.intuit.karate.core.ScenarioContext;
import com.intuit.karate.http.Cookie;
import org.apache.http.client.CookieStore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Field;
import java.time.ZonedDateTime;
import java.util.LinkedHashMap;
import java.util.Map;

import static com.intuit.karate.http.Cookie.*;
import static com.intuit.karate.http.HttpClient.construct;
import static org.junit.Assert.assertEquals;

public class ApacheHttpClientTest {

private static final Logger logger = LoggerFactory.getLogger(ApacheHttpClientTest.class);

private ScenarioContext getContext() {
FeatureContext featureContext = FeatureContext.forEnv();
CallContext callContext = new CallContext(null, true);
return new ScenarioContext(featureContext, callContext, null, null);
}

private Config getConfig() {
return new Config();
}

private Map<String, String> getCookieMapWithExpiredDate() {
ZonedDateTime currentDate = ZonedDateTime.now();
Map<String, String> cookieMap = new LinkedHashMap<>();
cookieMap.put(NAME, "testCookie");
cookieMap.put(VALUE, "tck");
cookieMap.put(DOMAIN, ".com");
cookieMap.put(PATH, "/");
cookieMap.put(EXPIRES,currentDate.minusDays(1).format(DTFMTR_RFC1123));
return cookieMap;
}

private Map<String, String> getCookieMapWithNonExpiredDate() {
ZonedDateTime currentDate = ZonedDateTime.now();
Map<String, String> cookieMap = new LinkedHashMap<>();
cookieMap.put(NAME, "testCookie");
cookieMap.put(VALUE, "tck");
cookieMap.put(DOMAIN, ".com");
cookieMap.put(PATH, "/");
cookieMap.put(EXPIRES, currentDate.plusDays(1).format(DTFMTR_RFC1123));
return cookieMap;
}

@Test
public void testExpiredCookieIsRemoved() throws NoSuchFieldException, IllegalAccessException {
com.intuit.karate.http.Cookie c = new Cookie(getCookieMapWithExpiredDate());
ApacheHttpClient httpClient = (ApacheHttpClient) construct(getConfig(), getContext());
httpClient.buildCookie(c);

Field cookieStoreField = httpClient.getClass().getDeclaredField("cookieStore");
cookieStoreField.setAccessible(true);
CookieStore fieldValue = (CookieStore) cookieStoreField.get(httpClient);
assertEquals(0, fieldValue.getCookies().size());
}

@Test
public void testNonExpiredCookieIsPersisted() throws NoSuchFieldException, IllegalAccessException {
com.intuit.karate.http.Cookie c = new Cookie(getCookieMapWithNonExpiredDate());
ApacheHttpClient httpClient = (ApacheHttpClient) construct(getConfig(), getContext());
httpClient.buildCookie(c);

Field cookieStoreField = httpClient.getClass().getDeclaredField("cookieStore");
cookieStoreField.setAccessible(true);
CookieStore fieldValue = (CookieStore) cookieStoreField.get(httpClient);
assertEquals(1, fieldValue.getCookies().size());
}
}


3 changes: 3 additions & 0 deletions karate-apache/src/test/resources/karate-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function fn() {
return { someConfig: 'someValue' }
}
2 changes: 2 additions & 0 deletions karate-apache/src/test/resources/karate-http.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
client.class=com.intuit.karate.http.apache.ApacheHttpClient

4 changes: 2 additions & 2 deletions karate-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,15 @@ The recommendation is that you prefer `chrome` for development, and once you hav

type | default port | default executable | description
---- | ------------ | ------------------ | -----------
[`chrome`](https://chromedevtools.github.io/devtools-protocol/) | 9222 | mac: `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`<br/>win: `C:/Program Files (x86)/Google/Chrome/Application/chrome.exe` | "native" Chrome automation via the [DevTools protocol](https://chromedevtools.github.io/devtools-protocol/)
[`chrome`](https://chromedevtools.github.io/devtools-protocol/) | 9222 | mac: `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` <br/>win: `C:/Program Files (x86)/Google/Chrome/Application/chrome.exe` | "native" Chrome automation via the [DevTools protocol](https://chromedevtools.github.io/devtools-protocol/)
[`playwright`](https://playwright.dev) | 4444 | `playwright` | see [`playwrightOptions`](#playwrightoptions) and [Playwright](#playwright)
[`msedge`](https://docs.microsoft.com/en-us/microsoft-edge/) | 9222 | mac: `/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge` <br/>win: `C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe` | the new Chromium based Microsoft Edge, using the [DevTools protocol](https://docs.microsoft.com/en-us/microsoft-edge/devtools-protocol-chromium)
[`chromedriver`](https://sites.google.com/a/chromium.org/chromedriver/home) | 9515 | `chromedriver` | W3C Chrome Driver
[`geckodriver`](https://github.com/mozilla/geckodriver) | 4444 | `geckodriver` | W3C Gecko Driver (Firefox)
[`safaridriver`](https://webkit.org/blog/6900/webdriver-support-in-safari-10/) | 5555 | `safaridriver` | W3C Safari Driver
[`msedgedriver`](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) | 9515 | `msedgedriver` | W3C Microsoft Edge WebDriver (the new one based on Chromium), also see [`webDriverSession`](#webdriversession)
[`mswebdriver`](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) | 17556 | `MicrosoftWebDriver` | Microsoft Edge "Legacy" WebDriver
[`iedriver`](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver) | 5555 | `IEDriverServer` | IE (11 only) Driver
[`msedge`](https://docs.microsoft.com/en-us/microsoft-edge/devtools-protocol/) | 9222 | `MicrosoftEdge` | *very* experimental - using the DevTools protocol
[`winappdriver`](https://github.com/Microsoft/WinAppDriver) | 4727 | `C:/Program Files (x86)/Windows Application Driver/WinAppDriver` | Windows Desktop automation, similar to Appium
[`android`](https://github.com/appium/appium/) | 4723 | `appium` | android automation via [Appium](https://github.com/appium/appium/)
[`ios`](https://github.com/appium/appium/) | 4723 |`appium` | iOS automation via [Appium](https://github.com/appium/appium/)
Expand Down
Loading