Fix remaining PR issues except build issues

This commit is contained in:
John Shewchuk 2019-09-01 10:08:10 -07:00
Родитель d6f2ff7d65
Коммит 71ab7cd12a
3 изменённых файлов: 28 добавлений и 27 удалений

Просмотреть файл

@ -2,63 +2,66 @@
<html> <html>
<head> <head>
<title>Simple Integration Tests</title>
</head> </head>
<body> <body>
<h2>You must be logged in to use tests</h2> <h2>Simple integration tests</h2>
<button onclick="test1()">GET /api/v1.0/me</button><br /> <p>You must be logged in to use tests</p>
<button onclick="test2()">GET /api/v1.0/profile</button><br /> <button onclick="test_get_me()">GET /api/v1.0/me</button><br />
<button onclick="test3()">PUT /api/v1.0/profile { "foo": "bar" }</button><br /> <button onclick="test_get_profile()">GET /api/v1.0/profile</button><br />
<br/> <button onclick="test_put_profile()">PUT /api/v1.0/profile { "foo": "bar" }</button><br />
<button onclick="test4()">GET /api/v1.0/cloudconnections/connection1</button><br /> <br />
<button onclick="test5()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "bar" }</button><br /> <button onclick="test_get_connection()">GET /api/v1.0/cloudconnections/connection1</button><br />
<button onclick="test6()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "baz" }</button><br /> <button onclick="test_put_connection()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "bar" }</button><br />
<button onclick="test7()">PATCH /api/v1.0/cloudconnections/connection1 { "updated": ${now} }</button><br /> <button onclick="test_put_connection_alt()">PUT /api/v1.0/cloudconnections/connection1 { "foo": "baz" }</button><br />
<button onclick="test8()">DELETE /api/v1.0/cloudconnections/connection1</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> <pre id='result'></pre>
<script> <script>
function fetchOptions(method, thing) { function fetchOptions(method, thing) {
return { method, body: JSON.stringify(thing), headers: { 'Content-Type': 'application/json' } }; return { method, body: JSON.stringify(thing), headers: { 'Content-Type': 'application/json' } };
} }
async function displayResponse(response) { async function displayResponse(response) {
let json = null; let json = null;
try { json = await response.json().catch(); } catch(err) { } try { json = await response.json().catch(); } catch (err) { }
let result = (response.ok ? '*success*' : '*failed*') + '\n' + (json ? JSON.stringify(json, undefined, 2) : '') ; let result = (response.ok ? '*success*' : '*failed*') + '\n' + (json ? JSON.stringify(json, undefined, 2) : '');
document.getElementById("result").innerHTML = result; document.getElementById("result").innerHTML = result;
} }
async function test1(e) { async function test_get_me(e) {
let response = await fetch('/api/v1.0/me'); 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'); let response = await fetch('/api/v1.0/profile');
displayResponse(response); displayResponse(response);
} }
async function test3(e) { async function test_put_profile(e) {
let response = await fetch('/api/v1.0/profile', fetchOptions("PUT", { foo: "bar" })); let response = await fetch('/api/v1.0/profile', fetchOptions("PUT", { foo: "bar" }));
displayResponse(response); displayResponse(response);
} }
async function test4(e) { async function test_get_connection(e) {
let response = await fetch('/api/v1.0/cloudconnections/connection1'); let response = await fetch('/api/v1.0/cloudconnections/connection1');
displayResponse(response); 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" })); let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("PUT", { foo: "bar" }));
displayResponse(response); 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" })); let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("PUT", { foo: "baz" }));
displayResponse(response); displayResponse(response);
} }
async function test7(e) { async function test_patch_connection(e) {
let now = (new Date(Date.now())).toISOString(); let now = (new Date(Date.now())).toISOString();
let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("PATCH", { updated: now })); let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("PATCH", { updated: now }));
displayResponse(response); displayResponse(response);
} }
async function test8(e) { async function test_delete_connection(e) {
let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("DELETE", undefined)); let response = await fetch('/api/v1.0/cloudconnections/connection1', fetchOptions("DELETE", undefined));
displayResponse(response); displayResponse(response);
} }

Просмотреть файл

@ -161,17 +161,16 @@ function ensureAuthenticatedApi(req: express.Request, res: express.Response, nex
} }
app.get('/', (req, res) => { app.get('/', (req, res) => {
let user = { ...req.user, oauthToken: '[removed]'}; const user = { ...req.user, oauthToken: '[removed]'};
res.render('index', { user }); res.render('index', { user });
}); });
app.get('/account', ensureAuthenticated, (req, res, next) => { app.get('/account', ensureAuthenticated, (req, res, next) => {
let user = { ...req.user, oauthToken: '[removed]'}; const user = { ...req.user, oauthToken: '[removed]'};
res.render('account', { user }); res.render('account', { user });
}); });
app.get('/login', (req, res, next) => { app.get('/login', (req, res, next) => {
log.info('testing');
passport.authenticate('azuread-openidconnect', passport.authenticate('azuread-openidconnect',
{ {
response: res, // required response: res, // required

Просмотреть файл

@ -30,7 +30,6 @@ export const creds = {
responseMode: 'form_post', responseMode: 'form_post',
// Required, the reply URL registered in AAD for your app // Required, the reply URL registered in AAD for your app
redirectUrl: baseUrl + redirectPath, redirectUrl: baseUrl + redirectPath,
// Required if we use http for redirectUrl // Required if we use http for redirectUrl