-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make over of old tests and api tests;
- Loading branch information
Daniel Thuermann
committed
Mar 16, 2022
1 parent
b806d81
commit 73d3731
Showing
3 changed files
with
108 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
/* Here are the first API tests. one can find some hints about it in the | ||
README.md. */ | ||
|
||
describe('OWASP juice shop - API', () => { | ||
|
||
it.only('Login', () => { | ||
cy.api({ | ||
method: 'POST', | ||
url: '/rest/user/login', | ||
body: { | ||
email: 'mc.safesearch@juice-sh.op', | ||
password: 'Mr. N00dles' | ||
} | ||
}).then( | ||
(response) => { | ||
expect(response.status).to.eq(200), | ||
expect(response.body.authentication.umail).to.eq('mc.safesearch@juice-sh.op'), | ||
cy.log(response.body.authentication.token).as('token'), | ||
cy.log(response.duration).as('duration') | ||
}) | ||
}) | ||
}) | ||
it('Login', () => { | ||
cy.api({ | ||
method: 'POST', | ||
url: '/rest/user/login', | ||
body: { | ||
email: 'mc.safesearch@juice-sh.op', | ||
password: 'Mr. N00dles' | ||
} | ||
}).then( | ||
(response) => { | ||
expect(response.status).to.eq(200), | ||
expect(response.body.authentication.umail).to.eq('mc.safesearch@juice-sh.op'), | ||
cy.log(response.body.authentication.token) | ||
.as('token'), | ||
cy.log(response.duration) | ||
.as('duration') | ||
}); | ||
}); | ||
|
||
it('Get legal text', () => { | ||
cy.api({ | ||
method: 'GET', | ||
url: '/ftp/legal.md' | ||
}).then( | ||
(response) => { | ||
expect(response.status).to.eq(200), | ||
cy.log(response.body) | ||
.as('legal'), | ||
cy.log(response.duration) | ||
.as('duration') | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,90 +1,90 @@ | ||
describe("OWASP juice shop", () => { | ||
before(() => { | ||
cy.clearCookies(); | ||
cy.clearLocalStorage(); | ||
}); | ||
|
||
it("should visit some subpages", () => { | ||
cy.visit("/#/about"); | ||
cy.visit("/#/photo-wall"); | ||
cy.request("/ftp/legal.md"); | ||
// cy.visit("/ftp/", { failOnStatusCode: false }); // TODO make it run again | ||
}); | ||
/* I have revised the test cases. Now they are almost independent of each other, | ||
except the first test is responsible for setting the cookies correctly for the | ||
following ones. */ | ||
|
||
it("should close the welcome banner and cookie notice", () => { | ||
cy.visit("/"); | ||
cy.get("button[aria-label='Close Welcome Banner']").click(); | ||
cy.get("a[aria-label='dismiss cookie message']").click(); | ||
describe("OWASP juice shop", () => { | ||
before(() => { | ||
cy.clearCookies(); | ||
cy.clearLocalStorage(); | ||
}); | ||
beforeEach(() => { | ||
Cypress.Cookies.preserveOnce('cookieconsent_status', | ||
'welcomebanner_status'); | ||
cy.visit("/"); | ||
}); | ||
|
||
it("should close the welcome banner and cookie notice", () => { | ||
cy.get("button[aria-label='Close Welcome Banner']") | ||
.click(); | ||
cy.get("a[aria-label='dismiss cookie message']") | ||
.click(); | ||
}); | ||
|
||
it("should type in credentials, press the login button and be logged in", | ||
() => { | ||
cy.get("button[aria-label='Show the shopping cart']").should("not.exist"); | ||
|
||
cy.get("button#navbarAccount").click(); | ||
cy.get("button#navbarLoginButton").click(); | ||
|
||
cy.url().should("include", "login"); | ||
|
||
cy.get("#login-form").within(() => { | ||
cy.get("#email").type("mc.safesearch@juice-sh.op"); | ||
cy.get("#password").type("Mr. N00dles"); | ||
cy.get("#rememberMe").click(); | ||
|
||
cy.get("#loginButton").click(); | ||
}); | ||
|
||
it("should navigate to login page", () => { | ||
cy.get("button#navbarAccount").click(); | ||
cy.get("button#navbarLoginButton").click(); | ||
cy.get("button[aria-label='Show the shopping cart']").should("exist"); | ||
}); | ||
|
||
cy.url().should("include", "login"); | ||
}); | ||
it("should visit some subpages", () => { | ||
cy.visit("/#/about"); | ||
cy.visit("/#/photo-wall"); | ||
}); | ||
|
||
it("should type in credentials, press the login button and be logged in", () => { | ||
cy.get("button[aria-label='Show the shopping cart']").should("not.exist"); | ||
it("should open profile and add username", () => { | ||
cy.get("button#navbarAccount").click(); | ||
cy.get("button#navbarLoginButton").click(); | ||
|
||
cy.get("#login-form").within(() => { | ||
cy.get("#email").type("mc.safesearch@juice-sh.op"); | ||
cy.get("#password").type("Mr. N00dles"); | ||
cy.get("#rememberMe").click(); | ||
cy.url().should("include", "login"); | ||
|
||
cy.get("#loginButton").click(); | ||
}); | ||
cy.get("#login-form").within(() => { | ||
cy.get("#email").type("mc.safesearch@juice-sh.op"); | ||
cy.get("#password").type("Mr. N00dles"); | ||
cy.get("#rememberMe").click(); | ||
|
||
cy.get("button[aria-label='Show the shopping cart']").should("exist"); | ||
cy.get("#loginButton").click(); | ||
}); | ||
|
||
it("should open profile and add username", () => { | ||
cy.get("button#navbarAccount").click(); | ||
cy.get("button#navbarLoginButton").click(); | ||
|
||
cy.url().should("include", "login"); | ||
cy.get("button[aria-label='Show the shopping cart']").should("exist"); | ||
|
||
cy.get("#login-form").within(() => { | ||
cy.get("#email").type("mc.safesearch@juice-sh.op"); | ||
cy.get("#password").type("Mr. N00dles"); | ||
cy.get("#rememberMe").click(); | ||
cy.visit("/profile"); | ||
|
||
cy.get("#loginButton").click(); | ||
}); | ||
cy.get("#username").clear().type("someUsername"); | ||
cy.get("#submit").click(); | ||
|
||
cy.get("button[aria-label='Show the shopping cart']").should("exist"); | ||
cy.visit("/rest/user/data-export", { failOnStatusCode: false }) | ||
}); | ||
|
||
cy.visit("/profile"); | ||
|
||
cy.get("#username").clear().type("someUsername"); | ||
cy.get("#submit").click(); | ||
|
||
cy.visit("/rest/user/data-export", { failOnStatusCode: false }) | ||
}); | ||
|
||
it("should open and close the item detail", () => { | ||
cy.visit("/"); | ||
cy.get("button[aria-label='Close Welcome Banner']").click(); | ||
cy.get("a[aria-label='dismiss cookie message']").click(); | ||
|
||
cy.get(".ribbon-card").first().click(); | ||
cy.get("mat-dialog-container").should("exist"); | ||
|
||
cy.get("button[aria-label='Close Dialog']").click(); | ||
cy.get("mat-dialog-container").should("not.exist"); | ||
}); | ||
it("should open and close the item detail", () => { | ||
cy.get(".ribbon-card").first().click(); | ||
cy.get("mat-dialog-container").should("exist"); | ||
|
||
it("should visit the score board", () => { | ||
cy.visit("/#/score-board"); | ||
}) | ||
cy.get("button[aria-label='Close Dialog']").click(); | ||
cy.get("mat-dialog-container").should("not.exist"); | ||
}); | ||
|
||
it("should enter XSS payload into the search field", () => { | ||
cy.get("button[aria-label='Close Welcome Banner']").click(); | ||
cy.get("a[aria-label='dismiss cookie message']").click(); | ||
it("should visit the score board", () => { | ||
cy.visit("/#/score-board"); | ||
}); | ||
|
||
const payload = '<iframe src="javascript:alert(`xss`)">'; | ||
it("should enter XSS payload into the search field", () => { | ||
const payload = '<iframe src="javascript:alert(`xss`)">'; | ||
|
||
cy.get("#searchQuery").click(); | ||
cy.get("#mat-input-0").clear().type(payload) + '{enter}'; | ||
}) | ||
cy.get("#searchQuery").click(); | ||
cy.get("#mat-input-0").clear().type(payload) + '{enter}'; | ||
}); | ||
}); |
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