Skip to content

Commit

Permalink
Tests for EB flow
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 3, 2025
1 parent 9d14772 commit 4835e37
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion client/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function authorizationUrl(state) {
}

export function me(config) {
if (config.local && 1 == 1) {
if (config.local && 1 != 1) {
let sub = "urn:service_admin";
sub = "urn:john";
//sub = "urn:paul";
Expand Down
2 changes: 0 additions & 2 deletions client/src/pages/Interrupt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export default function Interrupt({config, history}) {
saveContinueURL(config, continueUrl);
const errorStatus = parseInt( urlSearchParams.get("error_status"), 10);
// The user is already logged in, so mfa and aup are taken care of
debugger; // eslint-disable-line no-debugger

switch (errorStatus) {
case 97:
history.push(`/delay${window.location.search}`);
Expand Down
5 changes: 0 additions & 5 deletions client/src/pages/SecondFactorAuthentication.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {Toaster, ToasterType} from "@surfnet/sds";
import FeedbackDialog from "../components/Feedback";
import {ReactComponent as ResetTokenIcon} from "../icons/reset-token.svg";
import {redirectToProxyLocation} from "../utils/ProxyAuthz";
import {getParameterByName} from "../utils/QueryParameters";

const TOTP_ATTRIBUTE_NAME = "totp";
const NEW_TOTP_ATTRIBUTE_NAME = "newTotp";
Expand Down Expand Up @@ -49,9 +48,6 @@ class SecondFactorAuthentication extends React.Component {
}

componentDidMount() {
const state = getParameterByName("state", window.location.search);
debugger; // eslint-disable-line no-debugger
console.log(state);
const {user, update} = this.props;
if (user.rate_limited) {
this.setState({rate_limited: true, loading: false});
Expand Down Expand Up @@ -223,7 +219,6 @@ class SecondFactorAuthentication extends React.Component {
} else {
verify2fa(totp.join("")).then(r => {
this.props.refreshUser(user => { // eslint-disable-line no-unused-vars
debugger; // eslint-disable-line no-debugger
redirectToProxyLocation(r.location, this.props.history, config);
});
}).catch(e => {
Expand Down
4 changes: 2 additions & 2 deletions server/api/mock_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ def eb_interrupt_data():
def eb_stop_interrupt_flow():
if not os.environ.get("ALLOW_MOCK_USER_API", None):
raise Forbidden()
session["eb_interrupt_flow"] = None
return {}, 200
session.clear()
return {}, 204
6 changes: 3 additions & 3 deletions server/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ websockets==14.1
redis==5.2.1
pyotp==2.9.0
qrcode==8.0
Pillow==11.0.0
Pillow==11.1.0
PyJWT==2.10.1
Authlib==1.4.0
passlib==1.7.4
werkzeug==3.1.3
Flask-Executor==1.0.0
Flask-SocketIO==5.5.0
Flask-SocketIO==5.4.1
Flask-Cors==5.0.0
dnspython==2.7.0
signxml==4.0.2
signxml==4.0.3
bcrypt==4.2.1

git+https://github.com/SURFscz/flasgger@surf/main#egg=flasgger
Expand Down
11 changes: 11 additions & 0 deletions server/test/api/test_mock_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@ def test_eb_interrupt_data(self):
verified_data = XMLVerifier().verify(doc, x509_cert=cert).signed_xml
user_uid = verified_data.attrib.get("user_id")
self.assertEqual("urn:sarah", user_uid)

@allow_for_mock_user_api
def test_eb_stop_interrupt_flow(self):
self.login()
self.delete("/api/mock/stop_interrupt_flow", with_basic_auth=False)
user = self.client.get("/api/users/me").json
self.assertEqual(user["guest"], True)

def test_eb_stop_interrupt_flow_forbidden(self):
self.login()
self.delete("/api/mock/stop_interrupt_flow", with_basic_auth=False, response_status_code=403)
5 changes: 0 additions & 5 deletions server/test/api/test_user_saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,6 @@ def test_interrupt_eb_cert_url(self):
signed_root_str = etree.tostring(signed_root)
b64encoded_signed_root = base64.b64encode(signed_root_str)
url = self.app.app_config.engine_block.public_key_url
# responses.add(responses.GET,
# url,
# body=cert,
# status=200,
# content_type="application/x-pem-file")
responses.add(responses.GET, url, body=public_key, status=200, content_type="application/x-pem-file")
with requests.Session():
self.client.post(f"/api/users/interrupt?error_status={UserCode.SECOND_FA_REQUIRED.value}",
Expand Down

0 comments on commit 4835e37

Please sign in to comment.