Skip to content

Commit

Permalink
Update and move (#67)
Browse files Browse the repository at this point in the history
* Updated dependencies and moved to MarketSquare
* Test URLs configurable
* Redirect tests as noncritical because of httpbin issues
* BuiltIn import
* Run Linux tests against local httpbin and squid
  • Loading branch information
Hi-Fi authored Sep 17, 2020
1 parent 3229959 commit d3023c4
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 77 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ jobs:
matrix:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
java-version: [ 8, 11 ]

include:
- os: ubuntu-latest
mavenProfile: "-PlocalRun" # Running test on Linux using Docker endpoints

runs-on: ${{ matrix.os }}
name: Test on ${{ matrix.os }} with Java ${{ matrix.java-version }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v1.2.0
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
java-package: jdk
java-package: jdk
- name: Build with Maven
run: mvn -B verify --file pom.xml
run: mvn -B verify ${{ matrix.mavenProfile }} --file pom.xml

release:
needs: [build_and_test]
Expand All @@ -29,11 +34,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1.2.0
uses: actions/setup-java@v1
with:
java-version: 8
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@1221d1fa792cab948a772c5e7c1f3abe84aec3bf
uses: samuelmeuli/action-maven-publish@201a45a3f311b2ee888f252ba9f4194257545709
with:
gpg_private_key: ${{ secrets.gpg_private_key }}
gpg_passphrase: ${{ secrets.gpg_passphrase }}
Expand Down
144 changes: 119 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.hi-fi</groupId>
<groupId>com.github.MarketSquare</groupId>
<artifactId>robotframework-httprequestlibrary</artifactId>
<version>0.0.17-SNAPSHOT</version>
<packaging>jar</packaging>

<name>robotframework-httprequestlibrary</name>
<description>A Robot Framework library for HTTP request testing.</description>
<url>https://github.com/hi-fi/robotframework-httprequestlibrary</url>
<url>https://github.com/MarketSquare/robotframework-httprequestlibrary</url>

<distributionManagement>
<snapshotRepository>
Expand All @@ -31,7 +31,7 @@

<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/hi-fi/robotframework-httprequestlibrary/issues</url>
<url>https://github.com/MarketSquare/robotframework-httprequestlibrary/issues</url>
</issueManagement>

<licenses>
Expand All @@ -42,9 +42,9 @@
</license>
</licenses>
<scm>
<url>https://github.com/hi-fi/robotframework-httprequestlibrary</url>
<connection>scm:git:git://github.com/hi-fi/robotframework-httprequestlibrary.git</connection>
<developerConnection>scm:git:[email protected]:hi-fi/robotframework-httprequestlibrary.git</developerConnection>
<url>https://github.com/MarketSquare/robotframework-httprequestlibrary</url>
<connection>scm:git:git://github.com/MarketSquare/robotframework-httprequestlibrary.git</connection>
<developerConnection>scm:git:[email protected]:MarketSquare/robotframework-httprequestlibrary.git</developerConnection>
</scm>

<developers>
Expand All @@ -62,9 +62,15 @@
<keywords.class>HttpRequestLibrary</keywords.class>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<powermock.version>1.6.5</powermock.version>
<httpclient.version>0.0.6</httpclient.version>
<robotframework.maven.plugin.version>1.6.0</robotframework.maven.plugin.version>
<robotframework.version>3.1.2</robotframework.version>
<httpclient.version>0.0.7</httpclient.version>
<robotframework.maven.plugin.version>1.7.2</robotframework.maven.plugin.version>
<robotframework.version>3.2.2</robotframework.version>
<environment>default</environment>
<defaultTestServer>https://httpbin.org</defaultTestServer>
<defaultTestServerPort>443</defaultTestServerPort>
<defaultProxyPort>1234</defaultProxyPort>
<robotLogLevel>DEBUG</robotLogLevel>
<robotDefaultDisplayLogLevel>INFO</robotDefaultDisplayLogLevel>
</properties>

<dependencies>
Expand All @@ -87,22 +93,22 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.1</version>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.1</version>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand All @@ -117,7 +123,7 @@
<dependency>
<groupId>org.python</groupId>
<artifactId>jython</artifactId>
<version>2.7.2b3</version>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.robotframework</groupId>
Expand All @@ -127,14 +133,94 @@
</dependencies>

<profiles>
<profile>
<id>localRun</id>
<properties>
<environment>local</environment>
<localTestServer>http://localhost</localTestServer>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>localTestServerPort</portName>
<portName>localProxyPort</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.34.0</version>
<executions>
<execution>
<id>prepare-it-test-server</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<images>
<image>
<name>kennethreitz/httpbin:latest</name>
<alias>httpbin</alias>
<run>
<ports>
<port>localTestServerPort:80</port>
</ports>
<wait>
<log>(?s).*Booting worker with pid.*</log>
<time>10000</time>
</wait>
</run>
</image>
<image>
<name>sameersbn/squid:3.5.27-2</name>
<alias>proxy</alias>
<run>
<ports>
<port>localProxyPort:3128</port>
</ports>
<wait>
<log>(?s).*Accepting HTTP Socket connections at.*</log>
<time>10000</time>
</wait>
</run>
</image>
</images>
</configuration>
</execution>
<execution>
<id>remove-it-test-server</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploy</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -147,7 +233,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.1.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -161,7 +247,7 @@
<!-- Build the fat jar with all dependencies -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
Expand Down Expand Up @@ -257,11 +343,11 @@
</goals>
<configuration>
<!-- Prevent `gpg` from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
Expand Down Expand Up @@ -295,7 +381,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
Expand All @@ -304,7 +390,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -321,13 +407,21 @@
<goal>acceptance-test</goal>
</goals>
<configuration>
<logLevel>DEBUG:INFO</logLevel>
<logLevel>${robotLogLevel}:${robotDefaultDisplayLogLevel}</logLevel>
<extraPathDirectories>
<extraPathDirectory>target/robotframework-httprequestlibrary-${project.version}.jar</extraPathDirectory>
</extraPathDirectories>
<nonCriticalTags>
<nonCriticalTag>Non-Critical</nonCriticalTag>
<nonCriticalTag>Non-working_on_${environment}</nonCriticalTag>
</nonCriticalTags>
<variables>
<variable>environment:${environment}</variable>
<variable>localTestServer:${localTestServer}:${localTestServerPort}</variable>
<variable>localProxyPort:${localProxyPort}</variable>
<variable>defaultTestServer:${defaultTestServer}:${defaultTestServerPort}</variable>
<variable>defaultProxyPort:${defaultProxyPort}</variable>
</variables>
</configuration>
</execution>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static Boolean isDictionary(String testedString) {
protected PythonInterpreter initialValue() {
PythonInterpreter pythonInterpreter = new PythonInterpreter();
pythonInterpreter.exec("from robot.api import logger");
pythonInterpreter.exec("from robot.libraries.BuiltIn import BuiltIn");
return pythonInterpreter;
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/test/robotframework/acceptance/Delete.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ Resource common.robot
Force Tags DELETE
*** Test Cases ***
Delete Request With URL Params
Create Session httpbin http://httpbin.org
Create Session httpbin ${testServer}
&{params}= Create Dictionary key=value key2=value2
${resp}= Delete Request httpbin /delete ${params}
Should Be Equal As Strings ${resp.status_code} 200
Delete Request With No Data
Create Session httpbin http://httpbin.org
Create Session httpbin ${testServer}
${resp}= Delete Request httpbin /delete
Should Be Equal As Strings ${resp.status_code} 200
Delete Request With Data
Create Session httpbin http://httpbin.org debug=True
Create Session httpbin ${testServer} debug=True
&{data}= Create Dictionary name=bulkan surname=evcimen
${resp}= Delete Request httpbin /delete data=${data}
Should Be Equal As Strings ${resp.status_code} 200
Expand All @@ -26,7 +26,7 @@ Delete Request With Data

Delete Request With JSON Data
${JSON_DATA} Set Variable {"file":{"path":"/logo1.png"},"token":"some-valid-oauth-token"}
Create Session httpbin http://httpbin.org
Create Session httpbin ${testServer}
&{headers}= Create Dictionary Content-Type=application/json
${resp}= Delete Request httpbin /delete data=${JSON_DATA} headers=${headers}
Should Be Equal As Strings ${JSON_DATA} ${resp.json['data']}
13 changes: 8 additions & 5 deletions src/test/robotframework/acceptance/Get.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ Force Tags GET
*** Test Cases ***
Get Requests
Create Session google http://www.google.com
Create Session httpbin http://httpbin.org
Log ${testServer}
Create Session google https://www.google.com
Create Session httpbin ${testServer}
${resp}= Get Request google /
Should Be Equal As Strings ${resp.status_code} 200
${resp}= Get Request httpbin /
Should Be Equal As Strings ${resp.status_code} 200
Get Requests with Url Parameters
Create Session httpbin http://httpbin.org
Create Session httpbin ${testServer}
&{params}= Create Dictionary key=value key2=value2
${resp}= Get Request httpbin /get params=${params}
Should Be Equal As Strings ${resp.status_code} 200
Expand All @@ -37,14 +38,16 @@ Get With Auth
Should Be Equal As Strings ${resp.json['authenticated']} True
Get Request With Redirection
Create Session httpbin http://httpbin.org debug=True
[Tags] Non-working_on_default
Create Session httpbin ${testServer} debug=True
${resp}= Get Request httpbin /redirect/1
Should Be Equal As Strings ${resp.status_code} 200
${resp}= Get Request httpbin /redirect/1 allow_redirects=${true}
Should Be Equal As Strings ${resp.status_code} 200
Get Request Without Redirection
Create Session httpbin http://httpbin.org
[Tags] Non-working_on_default
Create Session httpbin ${testServer}
${resp}= Get Request httpbin /redirect/1 allow_redirects=${false}
${status}= Convert To String ${resp.status_code}
Should Start With ${status} 30
Loading

0 comments on commit d3023c4

Please sign in to comment.