-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: vérification erreur externalid
- Loading branch information
1 parent
81647a7
commit 649b970
Showing
7 changed files
with
92 additions
and
4 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
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,25 @@ | ||
""" | ||
Serveur python simulant un service web. | ||
Il n'est pas là pour faire les requêtes (ce sont les scripts de test qui les font) mais pour pour faire valider des ST. | ||
Utilisé comme service vers lequel on va être redirigé pour le test attribute release externalid. | ||
""" | ||
|
||
import urllib3 | ||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
from constants import CAS_BASE_URL, SERVICE_EXTERNALID_ERROR_URL | ||
from utils import validate_ticket_to_cas_and_return_attributes | ||
|
||
urllib3.disable_warnings() | ||
|
||
class RequestHandler(BaseHTTPRequestHandler): | ||
def do_GET(self): | ||
validate_ticket_to_cas_and_return_attributes(self, SERVICE_EXTERNALID_ERROR_URL, CAS_BASE_URL) | ||
|
||
def run(server_class=HTTPServer, handler_class=RequestHandler, port=8022): | ||
server_address = ('', port) | ||
httpd = server_class(server_address, handler_class) | ||
print(f'Starting server on port {port}...') | ||
httpd.serve_forever() | ||
|
||
if __name__ == '__main__': | ||
run() |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const cas = require("../cas.js"); | ||
const puppeteer = require('puppeteer'); | ||
const assert = require("assert"); | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch(cas.browserOptions()); | ||
|
||
try { | ||
const page = await browser.newPage(); | ||
const client = await page.createCDPSession(); | ||
const casHost = "https://localhost:8443"; | ||
const service = "http://localhost:8022/test" | ||
|
||
// Login to cas | ||
await cas.loginWith(page, casHost, service, "test1", "test") | ||
|
||
// Assert that an error page is given | ||
const pageContent = await page.content(); | ||
assert(pageContent.includes("<cas:authenticationFailure code=\"INVALID_AUTHENTICATION_CONTEXT\">")) | ||
|
||
process.exit(0) | ||
|
||
} catch (e) { | ||
cas.loge(e); | ||
process.exit(1) | ||
} finally { | ||
await browser.close(); | ||
} | ||
})(); |
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 @@ | ||
{ | ||
"@class": "org.apereo.cas.services.CasRegisteredService", | ||
"serviceId": "^http:\/\/localhost:8022\/.*", | ||
"name": "Service Test", | ||
"description": "Service de test pour externalid page erreur", | ||
"id": 22, | ||
"attributeReleasePolicy": { | ||
"@class": "org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy", | ||
"allowedAttributes": [ "java.util.ArrayList", [ "cn", "mail", "sn" ] ] | ||
}, | ||
"usernameAttributeProvider" : { | ||
"@class" : "org.apereo.cas.services.PrincipalExternalIdRegisteredServiceUsernameProvider", | ||
"internalServiceId": "SERVICE3" | ||
}, | ||
"webflowInterruptPolicy": { | ||
"@class": "org.apereo.cas.services.DefaultRegisteredServiceWebflowInterruptPolicy", | ||
"enabled": false | ||
} | ||
} |