Skip to content

Commit 49de037

Browse files
Login tests (#33)
* added custom webId profile with no oidcissuer for testing purposes * added second pod with bad webId profile for testing purposes * updated pods prepare script * created script to configure the pods with our custom files * added test for user trying to log in with webid without oidcissuer * created webId document with invalid rdf * added pod with invalid rdf document * setting the webid document of invalidWebId pod to an invalid document * added test for a user trying to log in with a webid that has an invalid webid document * added test for user trying to log in with invalid idp url * changed cypress open to run * Clean up * Remove commented lines in script * Typo * Add Markdown linter --------- Co-authored-by: Pieter Heyvaert <pheyvaer.heyvaert@ugent.be>
1 parent 8f19c8a commit 49de037

File tree

14 files changed

+479
-781
lines changed

14 files changed

+479
-781
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ dist-ssr
2626
pods*
2727

2828
lintPush.sh
29-
3029
cypress/screenshots

.markdownlint-cli2.cjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"use strict";
2+
3+
module.exports = {
4+
ignores: [ "node_modules/", "LICENSE.md", ".github/" ],
5+
6+
globs: [ "**/*.md" ],
7+
8+
config: {
9+
// Enable all markdownlint rules
10+
default: true,
11+
12+
MD004: {
13+
"style": "dash"
14+
},
15+
16+
// Set list indent level to 2
17+
MD007: { "indent": 2 },
18+
19+
// Enable line length check but exclude tables and code blocks
20+
MD013: {
21+
line_length: 120,
22+
tables: false,
23+
code_blocks: false
24+
},
25+
26+
// Allow multiple subheadings with the same content
27+
// across different section (#1 ##A ##B #2 ##A ##B)
28+
MD024: {
29+
allow_different_nesting: true
30+
},
31+
32+
// Set Ordered list item prefix to "ordered" (use 1. 2. 3. not 1. 1. 1.)
33+
MD029: { "style": "ordered" },
34+
35+
// Allow inline HTML
36+
MD033: false,
37+
}
38+
};

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ The underscore `_` here is crucial to make a clear distinction between name and
9090
### Representation Mapper
9191

9292
If you want to add your own type representations
93-
you can do this by adding your representation to the [typeMapper.js](./src/representationProvider/representationProvider.jsx) file.
93+
you can do this by adding your representation to the
94+
[typeMapper.js](./src/representationProvider/representationProvider.jsx) file.
9495
This can be useful for example when querying images.
9596
The result of the query is a reference to the image.
9697
By mapping a representation we can show the actual image instead of the reference.
@@ -115,7 +116,8 @@ The components get the following props:
115116
- `record` (the query result), an object of `RDF/JS` objects.
116117
- `variable` the variable name and key of `record`, a string.
117118

118-
`Hint` use the [Field components](https://marmelab.com/react-admin/doc/3.19/Fields.html#basic-fields) from `react-admin` to display the result.
119+
`Hint` use the [Field components](https://marmelab.com/react-admin/doc/3.19/Fields.html#basic-fields)
120+
from `react-admin` to display the result.
119121
They've already got styling matching that of `react-admin` and are easy to use.
120122

121123
`Warning` if you change the record object, the changed will still be present in the next render.
@@ -157,14 +159,18 @@ For testing we use [Cypress](https://www.cypress.io/).
157159
Keep the server running.
158160

159161
2. Start the Web application
162+
160163
```bash
161164
npm run dev
162165
```
166+
163167
Also keep this process running.
164168
3. Start the http proxy
169+
165170
```bash
166171
npm run start:proxy
167172
```
173+
168174
4. Start a server which denies all cors header
169175

170176
```bash
@@ -174,6 +180,7 @@ For testing we use [Cypress](https://www.cypress.io/).
174180
This process must also be active throughout the tests.
175181

176182
5. Finally, you can execute the tests by running
183+
177184
```bash
178185
npm run test
179186
```

cypress/e2e/spec.cy.js

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
describe("Web app", () => {
2-
it("Successfully loads.", () => {
2+
it("Successfully loads", () => {
33
cy.visit("/");
44
});
55

@@ -85,35 +85,56 @@ describe("Web app", () => {
8585
cy.contains("Ludwig van Beethoven");
8686
});
8787

88-
it("Log in and execute query on private data", () => {
88+
it("Log in with WebID with no OIDC issuer", () => {
8989
cy.visit("/");
9090

9191
cy.get('[aria-label="Profile"]').click();
9292
cy.contains('[role="menuitem"]', "Login").click();
9393

94-
cy.get('input[name="idp"]').clear();
95-
cy.get('input[name="idp"]').type("http://localhost:8080");
94+
cy.get('input[value="webId"]').click();
95+
96+
cy.get('input[name="idp"]')
97+
.clear();
98+
cy.get('input[name="idp"]')
99+
.type("http://localhost:8080/example2/profile/card#me");
96100
cy.contains("Login").click();
97101

98-
cy.get("input#email").type("hello@example.com");
99-
cy.get("input#password").type("abc123");
100-
cy.contains("button", "Log in").click();
101-
cy.contains("button", "Authorize").click();
102+
cy.contains("No IDP found");
103+
});
102104

103-
cy.url().should("eq", "http://localhost:5173/");
105+
it("Log in with invalid WebID document", () => {
106+
cy.visit("/");
104107

105-
cy.contains("A list of my favorite books").click();
106-
cy.contains("It Ends With Us");
108+
cy.get('[aria-label="Profile"]').click();
109+
cy.contains('[role="menuitem"]', "Login").click();
110+
111+
cy.get('input[value="webId"]').click();
112+
113+
cy.get('input[name="idp"]')
114+
.clear();
115+
cy.get('input[name="idp"]')
116+
.type("http://localhost:8080/invalidWebId/profile/card#me");
117+
cy.contains("Login").click();
118+
119+
cy.contains("Couldn't query the Identity Provider from the WebID");
107120
});
108121

109-
it("Query on private data unauthenticated", () => {
122+
it("Log in with an invalid IDP issuer", () => {
110123
cy.visit("/");
111124

112-
cy.contains("A list of my favorite books").click();
113-
cy.get("div").should("have.class", "MuiSnackbarContent-message");
125+
cy.get('[aria-label="Profile"]').click();
126+
cy.contains('[role="menuitem"]', "Login").click();
127+
128+
cy.get('input[name="idp"]')
129+
.clear();
130+
cy.get('input[name="idp"]')
131+
.type("https://facebook.com");
132+
cy.contains("Login").click();
133+
134+
cy.contains("Login failed");
114135
});
115136

116-
it('Querying resource with "bad" cors header, though a proxy should work', () => {
137+
it("Log in and execute query on private data", () => {
117138
cy.visit("/");
118139

119140
cy.get('[aria-label="Profile"]').click();
@@ -130,6 +151,20 @@ describe("Web app", () => {
130151

131152
cy.url().should("eq", "http://localhost:5173/");
132153

154+
cy.contains("A list of my favorite books").click();
155+
cy.contains("It Ends With Us");
156+
});
157+
158+
it("Query on private data unauthenticated", () => {
159+
cy.visit("/");
160+
161+
cy.contains("A list of my favorite books").click();
162+
cy.get("div").should("have.class", "MuiSnackbarContent-message");
163+
});
164+
165+
it('Querying resource with "bad" cors header, though a proxy should work', () => {
166+
cy.visit("/");
167+
133168
cy.contains("My idols").click();
134169
cy.get(".MuiSnackbarContent-message").should("not.exist");
135170
});

0 commit comments

Comments
 (0)