How to use logout method in autotest

Best Python code snippet using autotest_python

test_logout.py

Source:test_logout.py Github

copy

Full Screen

...84 expected = {85 'target': '/',86 }87 self.assertDictContainsSubset(expected, response.context_data)88 def test_client_logout(self):89 """ Verify the context includes a list of the logout URIs of the authenticated OpenID Connect clients.90 The list should only include URIs of the clients for which the user has been authenticated.91 """92 client = self._create_oauth_client()93 response = self._assert_session_logged_out(client)94 expected = {95 'logout_uris': [],96 'target': '/',97 }98 self.assertDictContainsSubset(expected, response.context_data)99 @mock.patch(100 'django.conf.settings.IDA_LOGOUT_URI_LIST',101 ['http://fake.ida1/logout', 'http://fake.ida2/accounts/logout', ]102 )...

Full Screen

Full Screen

logout.py

Source:logout.py Github

copy

Full Screen

...57 # We do not log here, because we have a handler registered to perform logging on successful logouts.58 request.is_from_logout = True59 # Get third party auth provider's logout url60 self.tpa_logout_url = tpa_pipeline.get_idp_logout_url_from_running_pipeline(request)61 logout(request)62 response = super().dispatch(request, *args, **kwargs)63 # Clear the cookie used by the edx.org marketing site64 delete_logged_in_cookies(response)65 return response66 def _build_logout_url(self, url):67 """68 Builds a logout URL with the `no_redirect` query string parameter.69 Args:70 url (str): IDA logout URL71 Returns:72 str73 """74 scheme, netloc, path, query_string, fragment = urlsplit(url)75 query_params = parse_qs(query_string)...

Full Screen

Full Screen

LogoutComponent.js

Source:LogoutComponent.js Github

copy

Full Screen

1/**2 * Created by Andy Likuski on 2020.09.113 * Copyright (c) 2020 Andy Likuski4 *5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:6 *7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.8 *9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.10 */11import * as R from 'ramda';12import * as ReactRouterDom from "react-router-dom";13import {14 componentAndPropsFor,15 composeViews,16 e,17 nameLookup,18 propsFor,19 renderChoicepoint,20 renderErrorDefault,21 renderLoadingDefault22} from '@rescapes/helpers-component';23import PropTypes from 'prop-types';24import * as RR from '@rescapes/ramda';25import {defaultNode} from '@rescapes/ramda';26import LogoutButtonComponent from './LogoutButtonComponent.js';27import {AuthenticationBox} from '../themeComponents/authenticationBox';28const {strPathOr, reqStrPathThrowing, strPathOrNullOk} = RR;29const {Redirect, useHistory, useLocation} = defaultNode(ReactRouterDom)30export const c = nameLookup({31 logout: true,32 logoutHeader: true,33 logoutBody: true,34 logoutButton: true,35 logoutLoading: true,36 logoutError: true37});38export default function LogoutComponent(props) {39 // Browser history hook40 const history = useHistory();41 // Browser location hook42 const location = useLocation();43 const allProps = LogoutComponent.views(R.mergeRight(props, {history, location}));44 const propsOf = propsFor(allProps.views);45 return e('div', propsOf(c.logout),46 LogoutComponent.choicepoint(allProps)47 );48}49/**50 *51 * @param {Object} history History object from the useHistory hook52 * @param {Object} location Location object from the useLocation hook53 * @param {Object} queryAuthenticatedUserLocalContainer Apollo query result about state of the user54 * @param views55 * @returns {Object}56 */57LogoutComponent.renderData = ({history, location, mutateDeleteTokenCookie, views}) => {58 const styledComponentAndProps = componentAndPropsFor(views);59 const propsOf = propsFor(views);60 // TODO Since refetchQueries doesn't work well (https://github.com/apollographql/apollo-client/issues/3633)61 // just listen to the result of the mutation and redirect to the referring page or /62 // Ideally we shouldn't have to redirect because the AppContainer's queries should rerun when the token goes63 // is the cache, but I don't know how to get a cache write to trigger dependent queries.64 if (strPathOr(false, 'result.data.deleteTokenCookie', mutateDeleteTokenCookie)) {65 return e(Redirect, {to: '/login'});66 }67 return e(AuthenticationBox, propsOf(c.logoutBody), [68 e('h2', propsOf(c.logoutHeader)),69 e(LogoutButtonComponent, propsOf(c.logoutButton))70 ]);71};72/**73 * Merges parent and state styles into component styles74 * @param style75 */76LogoutComponent.viewStyles = ({style}) => {77 return {78 [c.logout]: {},79 [c.logoutButton]: {},80 [c.logoutBody]: {}81 };82};83LogoutComponent.viewProps = props => {84 return {85 [c.logout]: {},86 [c.logoutBody]: {87 },88 [c.logoutButton]: {89 children: 'Logout'90 }91 };92};93LogoutComponent.viewEventHandlers = props => {94 return {95 [c.logoutButton]: {96 onClick: () => {97 reqStrPathThrowing('mutateDeleteTokenCookie.mutation', props)({98 variables: {}99 });100 }101 }102 };103};104/**105 * Adds to props.views for each component configured in viewEventHandlers, viewProps, and viewStyles106 * @param {Object} props this.props or equivalent for testing107 * @returns {Object} modified props108 */109LogoutComponent.views = composeViews(110 LogoutComponent.viewEventHandlers,111 LogoutComponent.viewProps,112 LogoutComponent.viewStyles113);114/**115 * Loading, Error, or Data based on the props.116 */117LogoutComponent.choicepoint = p => {118 return renderChoicepoint(119 {120 onError: renderErrorDefault(c.logoutError),121 onLoading: renderLoadingDefault(c.logoutLoading),122 onData: LogoutComponent.renderData123 },124 {}125 )(p);126};127LogoutComponent.propTypes = {128 style: PropTypes.shape().isRequired...

Full Screen

Full Screen

saveJS.js

Source:saveJS.js Github

copy

Full Screen

1// $(document).ready(function () {2$('#savetoDB').on('click', function () {3 let name = localStorage.getItem('charName');4 let race = localStorage.getItem('charRace');5 let charClass = localStorage.getItem('charClass');6 let charGender = localStorage.getItem('charGender');7 let charID = localStorage.getItem('charID');8 console.log(charID);9 if (charID === null) {10 createUserChar(name, race, charClass, charGender);11 } else {12 updateUserChar(name, race, charClass, charGender, charID);13 }14});15$(document).foundation();16//Logout button clears localstorage so a new user can login17$('#logout').on('click', function () {18 event.preventDefault();19 // $(document).foundation();20 //CREATES MODAL21 // create a div for the modal22 var logoutModal = $('<div>');23 // add class and ID for modal24 $(logoutModal).addClass('reveal revealStyle');25 $(logoutModal).attr('id', 'logoutModal');26 $(logoutModal).attr('data-reveal', '');27 // append the modal div to mainbody28 $('#mainBody').append(logoutModal);29 //LOGOUT MODAL TITLE30 var logoutTitle = $('<h1>');31 $(logoutTitle).text('Wait!');32 $(logoutModal).append(logoutTitle);33 //LOGOUT EXPLAINED34 var logoutDesc1 = $('<p>');35 $(logoutDesc1).text('Have you saved your character?');36 var logoutDesc2 = $('<p>');37 $(logoutDesc2).text(38 'If you would like to save your character for the next time you use DnD Buddy you will need to click on Save and Logout; otherwise click on Logout without Saving or Cancel.'39 );40 $(logoutModal).append(logoutDesc1);41 $(logoutModal).append(logoutDesc2);42 // LOGOUT BUTTONS43 let logoutBtn1 = $('<a>', {44 text: 'Save and Logout',45 class: 'btn btn-primary logout-button',46 id: 'logout1',47 href: '/logout',48 click: function () {49 let name = localStorage.getItem('charName');50 let race = localStorage.getItem('charRace');51 let charClass = localStorage.getItem('charClass');52 let charGender = localStorage.getItem('charGender');53 let charID = localStorage.getItem('charID');54 console.log(charID);55 if (charID === null) {56 createUserChar(name, race, charClass, charGender);57 } else {58 updateUserChar(name, race, charClass, charGender, charID);59 }60 localStorage.clear();61 // $('logout1').attr('href', '/logout');62 // $('logout1').click();63 $('#logoutModal').foundation('close');64 },65 });66 let logoutBtn2 = $('<a>', {67 text: 'Logout without Saving',68 class: 'btn btn-primary logout-button',69 id: 'logout2',70 href: '/logout',71 click: function () {72 localStorage.clear();73 $('#logoutModal').foundation('close');74 },75 });76 let logoutBtn3 = $('<a>', {77 text: 'Cancel',78 class: 'btn btn-primary logout-button',79 id: 'logout3',80 click: function () {81 $('#logoutModal').foundation('close');82 },83 });84 $(logoutModal).append(logoutBtn1);85 $(logoutModal).append(logoutBtn2);86 $(logoutModal).append(logoutBtn3);87 $(document).foundation();88 $('#logoutModal').foundation('open');89});90// update the user data with the existing character91function updateUserChar(name, race, charClass, charGender, charID) {92 $.ajax({93 url: '/api/save',94 type: 'PUT',95 data: {96 char_name: name,97 race: race,98 char_class: charClass,99 char_gender: charGender,100 char_id: charID,101 },102 });103}104// save the data to the database for a new character105function createUserChar(name, race, charClass, charGender, charID) {106 $.ajax({107 url: '/api/saveANewChar',108 type: 'POST',109 data: {110 char_name: name,111 race: race,112 char_class: charClass,113 char_gender: charGender,114 },115 });116}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful