Skip to content

Commit

Permalink
Merge branch 'master' into responsive-navbar-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
solderq35 committed Aug 8, 2023
2 parents 5d36257 + f7e2f28 commit 2a6788a
Show file tree
Hide file tree
Showing 34 changed files with 5,340 additions and 1,274 deletions.
4 changes: 3 additions & 1 deletion backend/sam_express.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
HTTPS.get(layerUrl, data => {
data.pipe(zipFile)
zipFile.on('finish', () => {
const extractor = Unzip.Extract({ path: 'express_build/opt' })
const extractor = Unzip.Extract({
path: 'express_build/opt'
})
FileSystem.createReadStream(layer + '.zip').pipe(extractor)
extractor.on('close', () => {
FileSystem.unlinkSync(layer + '.zip')
Expand Down
30 changes: 24 additions & 6 deletions backend/tests/utility/cors_test_utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
*/
exports.VerifyCORSResponse = (response, clientOrigin, serverOrigin) => {
if (clientOrigin.scheme !== serverOrigin.scheme) {
return { result: false, reason: 'CORS response scheme did not match request scheme.' }
return {
result: false,
reason: 'CORS response scheme did not match request scheme.'
}
}
if (clientOrigin.port !== serverOrigin.port) {
return { result: false, reason: 'CORS response port did not match request port.' }
return {
result: false,
reason: 'CORS response port did not match request port.'
}
}
// extract response headers. Not all of these need to be defined, which is OK.
if (response.headers) {
Expand All @@ -39,7 +45,10 @@ exports.VerifyCORSResponse = (response, clientOrigin, serverOrigin) => {

// Make sure we aren't re-directing
if ([301, 307, 308].includes(statusCode))
return { result: false, reason: 'CORS request external redirect not allowed' }
return {
result: false,
reason: 'CORS request external redirect not allowed'
}

// Make sure they have specified an Origin.
if (!allowedOrigin)
Expand All @@ -55,7 +64,10 @@ exports.VerifyCORSResponse = (response, clientOrigin, serverOrigin) => {
result: false,
reason: 'Credential is not supported if the CORS header ‘Access-Control-Allow-Origin’ is ‘*’'
}
return { result: true, reason: 'allowed origin is a wildcard, anyone can access this resource' }
return {
result: true,
reason: 'allowed origin is a wildcard, anyone can access this resource'
}
}

// Make sure the origin matches production
Expand All @@ -72,12 +84,18 @@ exports.VerifyCORSResponse = (response, clientOrigin, serverOrigin) => {
const validMethods = 'GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH'.split(', ')
for (method of allowedMethods.split(', ')) {
if (!validMethods.includes(method)) {
return { result: false, reason: `invalid token: '${method}' in CORS header ‘Access-Control-Allow-Methods` }
return {
result: false,
reason: `invalid token: '${method}' in CORS header ‘Access-Control-Allow-Methods`
}
}
}
}

return { result: true, resason: 'no error detected' }
}
return { result: false, reason: 'no headers specified, did you remember to use the Response class?' }
return {
result: false,
reason: 'no headers specified, did you remember to use the Response class?'
}
}
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=1028px,initial-scale=1.0" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-74257268-2"></script>
<script>
Expand Down
Loading

0 comments on commit 2a6788a

Please sign in to comment.