-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #968 from UniversityOfHelsinkiCS/trunk
Fix everything
- Loading branch information
Showing
17 changed files
with
100 additions
and
60 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
describe('Users tests', () => { | ||
beforeEach(() => { | ||
cy.server({ | ||
onAnyRequest: function (route, proxy) { | ||
if (Cypress.config().baseUrl.includes("http://localhost:1337/")) { | ||
proxy.xhr.setRequestHeader('uid', 'admink') | ||
proxy.xhr.setRequestHeader('shib-session-id', 'mock-shibboleth') | ||
proxy.xhr.setRequestHeader('hygroupcn', 'grp-oodikone-users') | ||
proxy.xhr.setRequestHeader('edupersonaffiliation', 'asdasd') | ||
} | ||
} | ||
}) | ||
console.log(Cypress.config().baseUrl) | ||
cy.visit(Cypress.config().baseUrl) | ||
cy.reload() | ||
cy.contains("Users").click() | ||
cy.contains("Enable or disable access to Oodikone") | ||
}) | ||
|
||
it("Admin mocking normal user shows only the mocked user's programmes", () => { | ||
cy.contains("mocking").should('not.exist') | ||
cy.contains("tr", "Normaalikäyttäjä").within(($row) => { | ||
cy.contains('button', 'Edit').click() | ||
}) | ||
cy.contains("Access rights").siblings().within(($row) => { | ||
cy.get("div[role='listitem']").should('have.length', 1).contains("Tietojenkäsittelytieteen kandiohjelma") | ||
}) | ||
|
||
cy.get('i.spy').click() | ||
cy.contains("mocking as normk") | ||
cy.contains("Study programme").click().siblings().contains("Search by class").click() | ||
cy.contains("label", "Study programme") | ||
cy.contains("label", "Study programme").siblings().within(($row) => { | ||
cy.get("div[role='option']").should('have.length', 1).contains("Tietojenkäsittelytieteen kandiohjelma") | ||
}) | ||
}) | ||
|
||
}) |
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
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
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
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
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
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
24 changes: 24 additions & 0 deletions
24
services/backend/oodikone2-backend/src/routes/superlogin.js
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const router = require('express').Router() | ||
const userService = require('../services/userService') | ||
|
||
router.post('/:uid', async (req, res) => { | ||
try { | ||
const asUser = req.params.uid | ||
const uid = req.decodedToken.mockedBy == null ? req.headers['uid'] : req.decodedToken.mockedBy | ||
if (req.headers['shib-session-id'] && uid) { | ||
console.log('super') | ||
const token = await userService.superlogin(uid, asUser) | ||
res.status(200).json({ token }) | ||
} else { | ||
res.status(401).json({ | ||
message: `Not enough headers login, uid: | ||
${req.headers.uid} session-id ${req.headers['shib-session-id']}` | ||
}).end() | ||
} | ||
} catch (err) { | ||
console.log(err.message) | ||
res.status(401).json({ message: 'problem with login', err: err.message }) | ||
} | ||
}) | ||
|
||
module.exports = router |
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
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
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
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
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,5 +1,5 @@ | ||
const { SECRET } = require('../conf-usageservice') | ||
|
||
const checkSecret = (req, res, next) => req.headers.secret == SECRET ? next() : res.status(403) | ||
const checkSecret = (req, res, next) => req.headers.secret == SECRET ? next() : res.status(403).end() | ||
|
||
module.exports = checkSecret |
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
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,5 +1,5 @@ | ||
const checkSecret = (req, res, next) => req.headers.secret == process.env.SECRET ? next() : res.status(403) | ||
const checkSecret = (req, res, next) => req.headers.secret == process.env.SECRET ? next() : res.status(403).end() | ||
|
||
|
||
module.exports = | ||
module.exports = | ||
checkSecret |
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