-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java] Fix FedCM command definition and tests (#14070)
Co-authored-by: Puja Jagani <puja.jagani93@gmail.com>
- Loading branch information
1 parent
359ac9a
commit c2d859c
Showing
13 changed files
with
232 additions
and
76 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
6 changes: 3 additions & 3 deletions
6
common/src/web/fedcm/fedcm.json → common/src/web/fedcm/config.json
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,7 +1,7 @@ | ||
{ | ||
"accounts_endpoint": "accounts.json", | ||
"client_metadata_endpoint": "client_metadata.json", | ||
"id_assertion_endpoint": "id_assertion", | ||
"signin_url": "/signin", | ||
"login_url": "/login" | ||
"id_assertion_endpoint": "id_assertion.json", | ||
"signin_url": "signin", | ||
"login_url": "login" | ||
} |
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,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>FedCM Example</title> | ||
</head> | ||
<body> | ||
<button id="triggerButton" onclick="triggerFedCm()">Trigger FedCM</button> | ||
<div id="result"></div> | ||
|
||
<script> | ||
// Use a relative path for the configURL | ||
let configURL = `https://${location.host}/fedcm/config.json`; | ||
console.log(configURL) | ||
let result = null; | ||
|
||
async function triggerFedCm() { | ||
console.log("Config URL:", configURL); | ||
try { | ||
let promise = await navigator.credentials.get({ | ||
identity: { | ||
providers: [{ | ||
configURL: configURL, | ||
clientId: '1', | ||
}] | ||
} | ||
}); | ||
result = promise; | ||
document.getElementById('result').innerText = JSON.stringify(result); | ||
} catch (error) { | ||
console.error("FedCM Error:", error); | ||
result = { error: error.message }; | ||
document.getElementById('result').innerText = JSON.stringify(result); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
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,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Login</title> | ||
</head> | ||
<body> | ||
<h1>Login Page</h1> | ||
<p>Login successful! This is a placeholder for the login process.</p> | ||
<a href="/">Return to Home</a> | ||
</body> | ||
</html> |
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,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Sign In</title> | ||
</head> | ||
<body> | ||
<h1>Sign In Page</h1> | ||
<p>This is a placeholder for the sign-in page.</p> | ||
<form action="/signin" method="post"> | ||
<label for="username">Username:</label> | ||
<input type="text" id="username" name="username" required> | ||
<br><br> | ||
<label for="password">Password:</label> | ||
<input type="password" id="password" name="password" required> | ||
<br><br> | ||
<button type="submit">Sign In</button> | ||
</form> | ||
</body> | ||
</html> |
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
46 changes: 46 additions & 0 deletions
46
java/test/org/openqa/selenium/environment/webserver/FedCmConfigHandler.java
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,46 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.environment.webserver; | ||
|
||
import java.io.UncheckedIOException; | ||
import java.util.Map; | ||
import org.openqa.selenium.remote.http.Contents; | ||
import org.openqa.selenium.remote.http.HttpHandler; | ||
import org.openqa.selenium.remote.http.HttpRequest; | ||
import org.openqa.selenium.remote.http.HttpResponse; | ||
|
||
class FedCmConfigHandler implements HttpHandler { | ||
|
||
@Override | ||
public HttpResponse execute(HttpRequest req) throws UncheckedIOException { | ||
HttpResponse response = new HttpResponse(); | ||
response.setHeader("Content-Type", "application/json"); | ||
response.setHeader("Cache-Control", "no-store"); | ||
|
||
response.setContent( | ||
Contents.asJson( | ||
Map.of( | ||
"accounts_endpoint", "accounts.json", | ||
"client_metadata_endpoint", "client_metadata.json", | ||
"id_assertion_endpoint", "id_assertion.json", | ||
"signin_url", "signin", | ||
"login_url", "login"))); | ||
|
||
return response; | ||
} | ||
} |
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
Oops, something went wrong.