Skip to content

Commit 5db57b1

Browse files
committed
added a test for restricted index sources
1 parent 73b712d commit 5db57b1

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

cypress/e2e/sources-from-indexfile.cy.js

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("Sources from index file", () => {
1212

1313
// Check that it indeed had 3 sources
1414
cy.get('.information-box').contains('Sources: 3');
15-
15+
1616
// Check if correct data is displayed
1717
cy.contains("http://www/example.com/data/component-c01");
1818
cy.contains("Component 1");
@@ -31,7 +31,7 @@ describe("Sources from index file", () => {
3131

3232
// Check that all 4 sources were used
3333
cy.get('.information-box').contains('Sources: 4');
34-
34+
3535
// Check if correct data is still displayed even if one source was unauthorized
3636
cy.contains("http://www/example.com/data/component-c01");
3737
cy.contains("Component 1");
@@ -50,11 +50,58 @@ describe("Sources from index file", () => {
5050

5151
// Check that the 4 sources were successfully merged
5252
cy.get('.information-box').contains('Sources: 4');
53-
53+
5454
// Check if correct data is still displayed even if one source was unauthorized and different sources were merged
5555
cy.contains("http://www/example.com/data/component-c01");
5656
cy.contains("Component 1");
5757
cy.contains("Material 1");
5858
});
5959

60+
it("Sources from an unauthorized source. Before and after log in.", () => {
61+
cy.visit("/");
62+
63+
cy.intercept('GET', 'http://localhost:8080/example/index-example-texon-only-AUTH').as('getRequest');
64+
65+
// Navigate to correct query
66+
cy.contains("For testing only").click();
67+
cy.contains("Sources from an index file (requiring authentication)").click();
68+
69+
// Wait for the request and assert the response
70+
cy.wait('@getRequest').then((interception) => {
71+
expect(interception.response.statusCode).to.equal(401);
72+
});
73+
74+
75+
cy.contains("http://www/example.com/data/component-c01").should("not.exist");
76+
cy.contains("Component 1").should("not.exist");
77+
cy.contains("Material 1").should("not.exist");
78+
79+
//log in
80+
cy.get('[aria-label="Profile"]').click();
81+
cy.contains('[role="menuitem"]', "Login").click();
82+
83+
cy.get('input[name="idp"]')
84+
.clear();
85+
cy.get('input[name="idp"]')
86+
.type("http://localhost:8080/example/profile/card#me");
87+
cy.contains("Login").click();
88+
89+
cy.get("input#email").type("hello@example.com");
90+
cy.get("input#password").type("abc123");
91+
cy.contains("button", "Log in").click();
92+
cy.contains("button", "Authorize").click();
93+
94+
cy.url().should("eq", "http://localhost:5173/");
95+
96+
//now try again
97+
cy.contains("For testing only").click();
98+
cy.contains("Sources from an index file (requiring authentication)").click();
99+
100+
cy.contains("http://www/example.com/data/component-c01").should("not.exist");
101+
cy.contains("Component 1").should("exist");
102+
cy.contains("Material 1").should("exist");
103+
})
104+
105+
106+
60107
});

src/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
"description": "Query components (including details about materials) with the sources obtained from index files that require authentication to retrieve said sources.",
179179
"sourcesIndex": {
180180
"url": "http://localhost:8080/example/index-example-texon-only-AUTH",
181-
"queryLocation": "/sourceQueries/index_example_texon_required_authentication.rq"
181+
"queryLocation": "/sourceQueries/index_example_texon_only_source_AUTH.rq"
182182
}
183183
},
184184

0 commit comments

Comments
 (0)