Skip to content

Commit 41d3018

Browse files
committed
added api key for reqres tests, added api key to secrets on github and updated maven workflow to use the api key from secret, made formatting changes to the testng xml files
1 parent 1a09eb4 commit 41d3018

File tree

8 files changed

+15
-10
lines changed

8 files changed

+15
-10
lines changed

.github/workflows/maven.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ jobs:
4444
run: mvn clean install -DskipTests
4545

4646
- name: Run tests
47-
run: mvn clean test
47+
env:
48+
API_KEY: ${{ secrets.REQRES_API_KEY }}
49+
run: mvn clean test -Dapi-key=$API_KEY
4850

4951
- name: Stop restful booker service
5052
run: docker compose -f ./docker-compose-restfulbooker.yml down --remove-orphans

docker-compose-ecommerce.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# To stop the execution, hit Ctrl+C, and then `docker compose -f docker-compose-ecommerce.yml down`
44
services:
55
restful-ecommerce:
6-
image: mfaisalkhatri/restful-ecommerce-app
6+
image: mfaisalkhatri/restful-ecommerce
77
ports:
88
- 3004:3004

src/test/java/io/github/mfaisalkhatri/api/reqres/tests/BaseTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package io.github.mfaisalkhatri.api.reqres.tests;
22

3+
import java.util.HashMap;
4+
import java.util.Map;
5+
36
import io.github.mfaisalkhatri.api.manager.RequestManager;
47
import org.testng.annotations.AfterClass;
58
import org.testng.annotations.BeforeClass;
69

7-
import java.util.HashMap;
8-
import java.util.Map;
9-
1010
/**
1111
* @author Faisal Khatri
1212
* @since 2/28/2023
@@ -15,13 +15,16 @@ public class BaseTest {
1515

1616
protected RequestManager manager;
1717

18+
1819
@BeforeClass
1920
public void setup() {
21+
String apiKey = System.getProperty ("api-key");
2022
this.manager = new RequestManager();
2123
this.manager.createPlaywright();
2224
final String baseUrl = "https://reqres.in";
2325
final Map<String, String> headers = new HashMap<>();
2426
headers.put("content-type", "application/json");
27+
headers.put ("x-api-key", apiKey);
2528
this.manager.setApiRequestContext(baseUrl, headers);
2629
}
2730

test-suite/testng-reqres.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
</class>
1515
</classes>
1616
</test>
17-
</suite> <!-- Suite -->
17+
</suite>

test-suite/testng-restfulecommerce-deleteorders.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
</class>
1313
</classes>
1414
</test>
15-
</suite>
15+
</suite>

test-suite/testng-restfulecommerce-partialupdateorder.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
</class>
1212
</classes>
1313
</test>
14-
</suite>
14+
</suite>

test-suite/testng-restfulecommerce-postandgetorder.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
</class>
1212
</classes>
1313
</test>
14-
</suite>
14+
</suite>

test-suite/testng-restfulecommerce-updateorder.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
</class>
2121
</classes>
2222
</test>
23-
</suite>
23+
</suite>

0 commit comments

Comments
 (0)