From ca8037ceeb9a0cddb0e5daeef1035e47eb37de08 Mon Sep 17 00:00:00 2001 From: damarisnicolae Date: Fri, 20 Sep 2024 10:59:35 +0300 Subject: [PATCH] Work in progress at e2e tests --- api/e2etests.yml | 108 +++++++++++++++++++++++++++++++++++ api/testsuite.yml | 71 ----------------------- bff/templates/view/home.html | 2 +- 3 files changed, 109 insertions(+), 72 deletions(-) create mode 100644 api/e2etests.yml delete mode 100644 api/testsuite.yml diff --git a/api/e2etests.yml b/api/e2etests.yml new file mode 100644 index 0000000..491157a --- /dev/null +++ b/api/e2etests.yml @@ -0,0 +1,108 @@ +version "2" +name: Users testsuite + +vars: + sql.url: "damaris:damarisub@(localhost:3306)/users" + api.url: "http://localhost:8080" + +testcases: + - name: init db + steps: + - type: sql + driver: mysql + dsn: "{{.sql.url}}" + commands: + - "INSERT INTO `users` (`jobtitle`, `firstname`, `lastname`, `email`, `phone`, `address`, `city`, `country`, `postalcode`, `dateofbirth`, `nationality`, `summary`, `workexperience`, `education`, `skills`, `languages`) VALUES ('Inginer Software', 'Sophye', 'Soph', 'sophyesoph@google.com', '07076965173', 'Str. Zambilelor nr.4', 'Timișoara', 'Romania', '010001', '1990-11-11', 'română')" + - "INSERT INTO `users` (`jobtitle`, `firstname`, `lastname`, `email`, `phone`, `address`, `city`, `country`, `postalcode`, `dateofbirth`, `nationality`, `summary`, `workexperience`, `education`, `skills`, `languages`) VALUES ('Inginer Software', 'Myriam', 'Myr', 'myriammyr@google.com', '07076965173', 'Str. Zambilelor nr.4', 'Timișoara', 'Romania', '010001', '1990-11-11', 'română')" + - name: GetUsers + steps: + - type: http + method: GET + headers: + Accept: application/json + Content-Type: application/json + url: "{{api.url}}/users" + assertions: + - result.statuscode ShouldEqual 200 + - result.bodyjson ShouldBeArray + - result.bodyjson.users[0] ShouldContainKey ID + - result.bodyjson.users[0] ShouldContainKey Firstname + - result.bodyjson.users[0].ID ShouldBeNumber + - result.bodyjson.users[0].Firstname ShouldBeString + - name: GetUser + steps: + - type: http + method: GET + headers: + Accept: application/json + Content-Type: application/json + url: "{{api.url}}/user" + assertions: + - result.statuscode ShouldEqual 200 + - result.bodyjson ShouldBeArray + - result.bodyjson.user[0] ShouldContainKey ID + - result.bodyjson.user[0] ShouldContainKey Firstname + - result.bodyjson.user[0].ID ShouldBeNumber + - result.bodyjson.user[0].Firstname ShouldBeString + - name: CreateUser + steps: + - type: http + method: POST + url: "{{api.url}}/user" + body: | + { + "Jobtitle": "Developer" + "Firstname": "Christian", + "Lastname": "Ungurean", + "Email": "christian.ungurean@yahoo.com", + "Phone": "07076965173", + "Address": "Str. Zambilelor nr.4", + "City": "Timișoara", + "Country": "România", + "Postalcode": "111111", + "Dateofbirth": "1990-11-11", + "Nationality": "română" + } + headers: + Content-Type: application/json + assertions: + - result.statuscode ShouldEqual 201 + - result.bodyjson ShouldContainKey Firstname + - result.bodyjson.Firstname ShouldEqual Christian + - result.bodyjson.Email ShouldEqual "christian.ungurean@yahoo.com" + - name: UpdateUser + steps: + - type: http + method: PUT + url: "{{.url}}/user/1" + body: | + { + "Jobtitle": "Developer" + "Firstname": "Christian", + "Lastname": "Ungurean", + "Email": "christian.ungurean2@yahoo.com", + "Phone": "07076965173", + "Address": "Str. Zambilelor nr.4", + "City": "Timișoara", + "Country": "România", + "Postalcode": "111111", + "Dateofbirth": "1990-11-11", + "Nationality": "română" + } + headers: + Content-Type: application/json + assertions: + - result.statuscode ShouldEqual 200 + - result.bodyjson ShouldContainKey Firstname + - result.bodyjson.Firstname ShouldEqual Christian + - result.bodyjson.Lastname ShouldEqual Ungurean + - result.bodyjson.Email ShouldEqual "christian.ungurean2@yahoo.com" + - name: DeleteUser + steps: + - type: http + method: DELETE + url: "{{.url}}/user/1" + headers: + Content-Type: application/json + assertions: + - result.statuscode ShouldEqual 204 diff --git a/api/testsuite.yml b/api/testsuite.yml deleted file mode 100644 index 2a7cee6..0000000 --- a/api/testsuite.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: APIIntegrationTest - -vars: - url: http://localhost:8080 - -testcases: - - name: GetUsers - steps: - - type: http - method: GET - headers: - Accept: application/json - Content-Type: application/json - url: "{{.url}}/users" - assertions: - - result.statuscode ShouldEqual 200 - - result.bodyjson ShouldBeArray - - result.bodyjson.users[0] ShouldContainKey ID - - result.bodyjson.users[0] ShouldContainKey Firstname - - result.bodyjson.users[0].ID ShouldBeNumber - - result.bodyjson.users[0].Firstname ShouldBeString - - name: CreateUser - steps: - - type: http - method: POST - url: "{{.url}}/user" - body: | - { - "Firstname": "Anne", - "Lastname": "Ungurean", - "Email": "anne.ungurean@yahoo.com" - } - headers: - Accept: application/json - Content-Type: application/json - assertions: - - result.statuscode ShouldEqual 201 - - result.bodyjson ShouldContainKey ID - - result.bodyjson.ID ShouldBeNumber - - result.bodyjson.Firstname ShouldEqual Anne - - result.bodyjson.Email ShouldEqual "anne.ungurean@yahoo.com" - - name: UpdateUser - steps: - - type: http - method: PUT - url: "{{.url}}/user/1" - body: | - { - "Firstname": "Anne", - "Lastname": "Ungurean", - "Email": "anne.ungurean@yahoo.com" - } - headers: - Accept: application/json - Content-Type: application/json - assertions: - - result.statuscode ShouldEqual 200 - - result.bodyjson ShouldContainKey Firstname - - result.bodyjson.Firstname ShouldEqual Anne - - result.bodyjson.Lastname ShouldEqual Ungurean - - result.bodyjson.Email ShouldEqual "anne.ungurean@yahoo.com" - - name: DeleteUser - steps: - - type: http - method: DELETE - url: "{{.url}}/user/1" - headers: - Accept: application/json - Content-Type: application/json - assertions: - - result.statuscode ShouldEqual 204 diff --git a/bff/templates/view/home.html b/bff/templates/view/home.html index 86d76a4..f90d43b 100644 --- a/bff/templates/view/home.html +++ b/bff/templates/view/home.html @@ -41,6 +41,6 @@ SIGNUP - +