Problems in Playwright when running a test within Microsoft login - automated-tests

Details:
Currently I have a problem with Playwright. A test build of a website has a normal login with username and password. This login also works in the test, but after the login another query by Microsoft Login follows. The recorder of Playwright also records this login, but then does not resolve it when the test is executed.
Steps to reproduce:
1.) Login with Email (Mainpage)
2nd) After login appears query by Microsoft login (Will be recorded by Playwrigt recorder as well).
3) During the execution only the first login is noticed, but the Microsoft login is not executed (password is not entered).
Tooling:
Playwright (Full Installation/ Functional)
Python 3.10
Code:
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
# Open new page
page = context.new_page()
# Go to https://xxx.dev/
page.goto("https://xxx.dev/")
# Click [placeholder="Bitte gib deine Email Adresse ein"]
page.locator("[placeholder=\"Bitte gib deine Email Adresse ein\"]").click()
# Fill [placeholder="Bitte gib deine Email Adresse ein"]
page.locator("[placeholder=\"Bitte gib deine Email Adresse ein\"]").fill("youremai#.com")
# Click button:has-text("Einloggen")
page.locator("button:has-text(\"Einloggen\")").click()
page.wait_for_url("https://login.live.com/oauth20_xxx")
# Click #lightbox
page.locator("#lightbox").click()
# Click [placeholder="Kennwort"]
page.locator("[placeholder=\"Kennwort\"]").click()
# Fill [placeholder="Kennwort"]
page.locator("[placeholder=\"Kennwort\"]").fill("xxx")
# Click text=Anmelden
page.locator("text=Anmelden").click()
page.wait_for_url("https://xxx.dev")
# Click text=Nein
page.locator("text=Nein").click()
page.wait_for_url("https://xxx.dev/")
# Click text=×For the best user experience and a quick tour through the app, please use your >> button
page.locator("text=×For the best user experience and a quick tour through the app, please use your >> button").click()
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)

Related

Asp.net webfroms Google login not working

I have the project and users are login into their account by using Google login I created another project in the Google console developer portal to login with gmail now I got this below error message
Code: 403 Message: Legacy People API has not been used in project {PROJECTID} before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project={PROJECTID} then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
I followed this URl and https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project={PROJECTID}
but the page show up this below error many times I click on Retry button nothing has changed.
Error alert in Google Console
I have followed this articles https://www.aspsnippets.com/Articles/Login-with-Google-Account-API-in-ASPNet-and-get-Google-Plus-Profile-details.aspx
The code
GoogleConnect.ClientId = "CODE-1545454545545bpqhocrakp.apps.googleusercontent.com"
GoogleConnect.ClientSecret = "KHDFIUHUHDJHSLDSKJ"
GoogleConnect.RedirectUri = "https://mywebsitedomain.com/Login"
Dim code As String = Request.QueryString("code")
Dim json As String = GoogleConnect.Fetch("me", code)
Dim profile As GoogleProfile = New JavaScriptSerializer().Deserialize(Of GoogleProfile)(json)

Can't reset user's password in Google Identity Toolkit: "CAPTCHA_CHECK_FAILED"

I'm trying to setup my Google Identity Toolkit so users can reset their passwords. I'm following the documentation here: https://developers.google.com/identity/toolkit/web/required-endpoints#send_email_url
I'm using the PHP Gitkit Client outlined here: https://github.com/google/identity-toolkit-php-client/blob/master/src/GitkitClient.php
Specifically the function getOobResults() on line 307 seems to be unhappy for some reason. Here's where I'm at:
User sets up account and logs in successfully
User then logs out and starts to log back in, enters email in and clicks "Forgot password"
reCaptcha is shown, click check box and then hit continue
At this point my 'Send Email URL' endpoint (gitkitEmail.php) is successfully called and the following POST is set to it (dropping the full '&response' param since it goes on for a while):
action=resetPassword&email=xodfebefa%40nada.ltd&challenge&response=03ACgFB9tGlNt2KAGhrVY....
I then take that string and parse it using parse_str(); since getOobResults() is looking for an array. However, response I get back is always:
{
"response_body": {
"error": "CAPTCHA_CHECK_FAILED"
}
}
I searched around but can't find any details on this error. Any help would be appreciated. I don't have a reCaptcha setup anywhere on my site, unsure if this is expecting me to do that and that's why it's failing? Also, I did bump all my code to a production environment and got the same error there as I did on my localhost.

Shiny server-side navigate to URL

I have a shiny app, and sometimes the session can end (server timeout, data error, etc). This currently leaves them on a greyed out screen of the app.
To be more user friendly, I would like to refresh the user's session, or redirect them to the landing page of the app when this happens, so they can continue with what they were doing.
I would also like the code to work locally on my machine when coding, and when hosted on the Linux server. I am planning on using session$clientData$url_pathname to make this work. I currently (have in server.R) something like:
session$onSessionEnded({
# (1) Get the current url
currURL<-session$clientData$url_pathname
# (2) Go to the current URL
#-----------------------------------------------------------------
# I would like to refresh the browser here, using currURL as the path
#-----------------------------------------------------------------
# (3) Clear all session data
rm(list=ls(all=TRUE))
})
What command could I use in step (2) above to do the equivalent of the following in ui.R?
tags$a(href = "www.my-variable-url.org", "Click here to refresh the current URL")
Thanks

How do i get the web browser password store to remember R/Shiny passwords?

The problem
I have a shiny application that requires user to login to access the underlying dataset.
The username and password are collected from form fields and submitted via a RESTful API on another server to get an access token which is used in future requests. I haven't included those details in this example.
I want to get the web browser to remember the login details and login automatically, but can't quite see how.
What I tried
In my first implementation, the <input type="text" name="username"> and <input type="password" name="password"> plus an actionButton were dynamically added to the page. This forced the user to re-login each time the shiny application was restarted, which was complex for development and unpleasant for users.
I then found https://gist.github.com/kostiklv/968927 which details the conditions for having the web browser remember the password and log in.
Shiny works on one page, so I couldn't have a separate login page (this would generate a new shiny session, discarding the login!).
I have tried various combinations of things, here is the closest I have got. This script correctly fills in a past password, but the user still has to manually hit submit.
Example code
Note that I have a custom hack my shiny in to enable type="password" to be treated the same as type="text". See bottom of question for access to this code
save this code as login.R then run R and type source("login.R")
write("","blank.html")
require(shiny)
addResourcePath("login",tools:::file_path_as_absolute("./"))
runApp(list(
ui=bootstrapPage(
tags$form(action="#",target="loginframe",
tags$input(id="username",type="text",placeholder="Username"),
tags$input(id="password",type="password",placeholder="Password"),
tags$input(id="loginButton",class="btn btn-primary",type="submit",value="Login")
),
tags$iframe(name="loginframe",src="login/blank.html",style="display:none")
),
server=function(input, output) {
observe({message(
"username ",input$username,"\n",
"password ",input$password,"\n"
)})
})
)
Analysis of what happened
Note that the presence of an html input submit button seems to tell shiny that it should only update the inputs once every submit. Without the submit button shiny updates its inputs every keystroke.
The same is true for shiny's submitButton.
Leaving the form but removing the button allows input$username and input$password to reach the server code, but...
To enable both conventional user login and automated login, I need the button to avoid repeated attempts to authenticate (which might cause problems) for partial usernames and passwords.
Log of what happened
Here are the console logs from the tests
Log with a submit button:
username
password
<enter username AA and password BB>
*no update*
<hit submit>
*browser requests to save password / yes*
username A
password B
<refresh page>
username
password
* onscreen form inputs are populated *
<hit submit>
username A
password B
Log without a submit button
Comment out
tags$input(id="loginButton",class="btn btn-primary",type="submit",value="Login")
and the preceding comma
note you may want to tell your browser to forget localhost web passwords for now.
username
password
<enter username AA and password BB>
username A
password
username AA
password
username AA
password B
password BB
<refresh browser>
* onscreen form inputs are not populated *
* browser requests to save password *
username
password
<refresh browser>
* onscreen form inputs are populated *
username
password
username AA
username BB
Shiny patch to enable password handling:
Install using library(devtools)
install_github("shiny","alexbbrown",ref="password-field")
Or download and install manually:
https://github.com/alexbbrown/shiny.git (branch password-field)
Or patch your shiny manually:
index 9b63c7b..15377d8 100644
--- a/inst/www/shared/shiny.js
+++ b/inst/www/shared/shiny.js
## -1336,7 +1336,7 ##
var textInputBinding = new InputBinding();
$.extend(textInputBinding, {
find: function(scope) {
- return $(scope).find('input[type="text"]');
+ return $(scope).find('input[type="text"],input[type="password"]');
},
getId: function(el) {
return InputBinding.prototype.getId.call(this, el) || el.name;
cf Password field using R Shiny framework
I was looking for something similar, and trestletech's fantastic package shinyStore worked for me.
It enables HTML5 client-side data storage for any data in your shiny app.
The github page is here, and an example of how it works is here.
You may wish to read the "Security" section on the README and ensure it is secure enough for your purposes.
I believe that you can use postForm() from RCurl package to perform a regular HTTP form submit request (unless Shiny would interfere with this functionality, which is based on using underlying libcurl library). For an example code, please see function srdaLogin() in my R module "getSourceForgeData.R": https://github.com/abnova/diss-floss/blob/master/import/getSourceForgeData.R.

Login fails on Subtext

I have just downloaded subtext 2.5 source code and manage to run it on Visual Studio dev server. The problem is that whenever I try to navigate to admin/.. it redirects me to login page and it's not accepting default login credentials that are, I suppose, haacked and password respectively. But I was unable to login to the site.
Subtext_Host table of db contains following entry:
userid= Haacked, password= sIHb6F4ew//D1OfQInQAzQ== salt=KrPog8xD4kKBwW35zBxxCA== email=haacked#gmail.com datecreatedutc = 2011-06-11 21:37:29.533
I also tried resetting the password as described here (scroll to bottom) but to no avail.
The password you have reset is the Hostadmin password, accessible via http://<yoururl>/hostadmin/default.aspx by logging in there you should be able to reset the password for the particular blog you are interested in.

Resources