Fix remaining PR issues except build issues
This commit is contained in:
Родитель
d6f2ff7d65
Коммит
71ab7cd12a
|
@ -2,63 +2,66 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<title>Simple Integration Tests</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>You must be logged in to use tests</h2>
|
||||
<button onclick="test1()">GET /api/v1.0/me</button><br />
|
||||
<button onclick="test2()">GET /api/v1.0/profile</button><br />
|
||||
<button onclick="test3()">PUT /api/v1.0/profile { "foo": "bar" }</button><br />
|
||||
<br/>
|
||||
<button onclick="test4()">GET /api/v1.0/cloudconnections/connection1</button><br />
|
||||
<button onclick="test5()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "bar" }</button><br />
|
||||
<button onclick="test6()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "baz" }</button><br />
|
||||
<button onclick="test7()">PATCH /api/v1.0/cloudconnections/connection1 { "updated": ${now} }</button><br />
|
||||
<button onclick="test8()">DELETE /api/v1.0/cloudconnections/connection1</button><br />
|
||||
<h2>Simple integration tests</h2>
|
||||
<p>You must be logged in to use tests</p>
|
||||
<button onclick="test_get_me()">GET /api/v1.0/me</button><br />
|
||||
<button onclick="test_get_profile()">GET /api/v1.0/profile</button><br />
|
||||
<button onclick="test_put_profile()">PUT /api/v1.0/profile { "foo": "bar" }</button><br />
|
||||
<br />
|
||||
<button onclick="test_get_connection()">GET /api/v1.0/cloudconnections/connection1</button><br />
|
||||
<button onclick="test_put_connection()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "bar" }</button><br />
|
||||
<button onclick="test_put_connection_alt()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "baz" }</button><br />
|
||||
<button onclick="test_patch_connection()">PATCH /api/v1.0/cloudconnections/connection1 { "updated": ${now} }</button><br />
|
||||
<button onclick="test_delete_connection()">DELETE /api/v1.0/cloudconnections/connection1</button><br />
|
||||
|
||||
<pre id='result'></pre>
|
||||
|
||||
<script>
|
||||
function fetchOptions(method, thing) {
|
||||
return { method, body: JSON.stringify(thing), headers: { 'Content-Type': 'application/json' } };
|
||||
}
|
||||
|
||||
|
||||
async function displayResponse(response) {
|
||||
let json = null;
|
||||
try { json = await response.json().catch(); } catch(err) { }
|
||||
let result = (response.ok ? '*success*' : '*failed*') + '\n' + (json ? JSON.stringify(json, undefined, 2) : '') ;
|
||||
try { json = await response.json().catch(); } catch (err) { }
|
||||
let result = (response.ok ? '*success*' : '*failed*') + '\n' + (json ? JSON.stringify(json, undefined, 2) : '');
|
||||
document.getElementById("result").innerHTML = result;
|
||||
}
|
||||
|
||||
async function test1(e) {
|
||||
async function test_get_me(e) {
|
||||
let response = await fetch('/api/v1.0/me');
|
||||
displayResponse(response);
|
||||
displayResponse(response);
|
||||
}
|
||||
async function test2(e) {
|
||||
async function test_get_profile(e) {
|
||||
let response = await fetch('/api/v1.0/profile');
|
||||
displayResponse(response);
|
||||
}
|
||||
async function test3(e) {
|
||||
async function test_put_profile(e) {
|
||||
let response = await fetch('/api/v1.0/profile', fetchOptions("PUT", { foo: "bar" }));
|
||||
displayResponse(response);
|
||||
}
|
||||
async function test4(e) {
|
||||
async function test_get_connection(e) {
|
||||
let response = await fetch('/api/v1.0/cloudconnections/connection1');
|
||||
displayResponse(response);
|
||||
}
|
||||
async function test5(e) {
|
||||
async function test_put_connection(e) {
|
||||
let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("PUT", { foo: "bar" }));
|
||||
displayResponse(response);
|
||||
}
|
||||
async function test6(e) {
|
||||
async function test_put_connection_alt(e) {
|
||||
let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("PUT", { foo: "baz" }));
|
||||
displayResponse(response);
|
||||
}
|
||||
async function test7(e) {
|
||||
async function test_patch_connection(e) {
|
||||
let now = (new Date(Date.now())).toISOString();
|
||||
let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("PATCH", { updated: now }));
|
||||
displayResponse(response);
|
||||
}
|
||||
async function test8(e) {
|
||||
async function test_delete_connection(e) {
|
||||
let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("DELETE", undefined));
|
||||
displayResponse(response);
|
||||
}
|
||||
|
|
|
@ -161,17 +161,16 @@ function ensureAuthenticatedApi(req: express.Request, res: express.Response, nex
|
|||
}
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
let user = { ...req.user, oauthToken: '[removed]'};
|
||||
const user = { ...req.user, oauthToken: '[removed]'};
|
||||
res.render('index', { user });
|
||||
});
|
||||
|
||||
app.get('/account', ensureAuthenticated, (req, res, next) => {
|
||||
let user = { ...req.user, oauthToken: '[removed]'};
|
||||
const user = { ...req.user, oauthToken: '[removed]'};
|
||||
res.render('account', { user });
|
||||
});
|
||||
|
||||
app.get('/login', (req, res, next) => {
|
||||
log.info('testing');
|
||||
passport.authenticate('azuread-openidconnect',
|
||||
{
|
||||
response: res, // required
|
||||
|
|
|
@ -30,7 +30,6 @@ export const creds = {
|
|||
responseMode: 'form_post',
|
||||
|
||||
// Required, the reply URL registered in AAD for your app
|
||||
|
||||
redirectUrl: baseUrl + redirectPath,
|
||||
|
||||
// Required if we use http for redirectUrl
|
||||
|
|
Загрузка…
Ссылка в новой задаче