Skip to content

Commit

Permalink
fix(tests): CGI test
Browse files Browse the repository at this point in the history
  • Loading branch information
dantol29 committed May 24, 2024
1 parent e948f3c commit d8bbf38
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 38 deletions.
62 changes: 52 additions & 10 deletions conf/eval.conf
Original file line number Diff line number Diff line change
@@ -1,33 +1,75 @@
server {
listen 127.0.0.1:8080;
server_name localhost;
listen 8080;
server_name www.test.com;
allow_methods GET POST DELETE;
autoindex on;
root /var/;
error_page 404 html/404_salad.html;
upload_path /upload/;
error_page 404 40.html;
cgi_ext .cgi;
client_max_body_size 1000;
location /google {
location /admin {
return http://google.com;
index admin.html;
allow_methods GET POST;
}
location /cgi-bin/ {
cgi_ext .cgi .py;
autoindex off;
}
}

server {
listen 8081;
listen 8080;
server_name www.example.com;
allow_methods GET DELETE;
allow_methods GET POST;
autoindex on;
root var/;
location / {
index index.html;
allow_methods GET POST;
upload_path upload/;
}
}
server {
listen 8081;
server_name www.php_site.com;
allow_methods GET POST DELETE;
autoindex off;
root var/;
}
server {
listen 8080;
autoindex on;
cgi_ext .cgi;
server_name www.development_site;
limit_conn 3;
allow_methods GET POST DELETE;
root var/;
}
server {
listen 8080;
server_name www.python_site.com;
index bla.html;
allow_methods POST DELETE;
client_max_body_size 5;
autoindex off;
root var/;
}

server {
listen 8082;
server_name www.php_site.com;
listen 8080;
server_name www.saladbook.xyz;
allow_methods GET POST DELETE;
autoindex on;
cgi_ext .cgi .py;
root var/;
}

server {
listen 8080;
server_name www.saladbook;
limit_conn 2;
allow_methods GET POST DELETE;
client_max_body_size 1000;
autoindex off;
root var/;
}
4 changes: 2 additions & 2 deletions tests/CGI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ int main(void)

// NOTE: when you run a test, configfile and dir structure should fit
// salad(serverAddress); // standard routing tests
// delete_entry(serverAddress); // DELETE request
delete_entry(serverAddress); // DELETE request
std::cout << "Waiting for the server to delete the entry..." << std::endl;
sleep(2);
std::cout << "\033[34m" << std::endl << "Continuing with the tests..." << "\033[0m" << std::endl;
add_entry(serverAddress); // POST request
// add_entry(serverAddress); // POST request

if (is_error)
exit(1);
Expand Down
42 changes: 42 additions & 0 deletions var/www.python_site.com/bla.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Our Web Service</title>
</head>
<body>
<header>
<div class="container">
<h1>Welcome to Our Web Service</h1>
</div>
</header>
<nav>
<div class="container">
<a href="/development_site/cgi-bin/hello_py.cgi">Development Site</a>
<a href="/perl_site/index.html">Perl Site</a>
<a href="/php_site/index.html">PHP Site</a>
<a href="/www.python_site.com/index.html">Python Site</a>
</div>
</nav>
<div class="container">
<article>
<h2>BLA</h2>
<p>Welcome to our multi-faceted web server. Here, you can find a variety of web applications and sites ranging from development tools to language-specific sites. Whether you're here to explore our Perl, PHP, or Python projects, or to delve into our development tools, there's something for everyone.</p>
<p>Please use the navigation above to explore our sites.</p>
</article>
</div>
<form action="/" method="post" enctype="multipart/form-data">
<label for="file">Choose a file:</label>
<input type="file" id="file" name="file">
<br>
<input type="submit" value="Upload">
</form>
<h2>Upload Multiple Files</h2>
<form action="/" method="post" enctype="multipart/form-data">
<input type="file" name="files[]" multiple>
<br>
<input type="submit" value="Upload Files">
</form>
</body>
</html>
53 changes: 29 additions & 24 deletions var/www.python_site.com/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,40 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Planet Python</title>
<title>Welcome to Our Web Service</title>
</head>
<body>
<header>
<h1>Welcome to our Pythons website</h1>
<div class="container">
<h1>Welcome to Our Web Service</h1>
</div>
</header>
<main>
<section>
<h2>About Pythons</h2>
<p>Pythons are a woderul animals, they are one of the largest species of snakes found in the tropical regions of Africa, Asia, and Australia. They are non-venomous constrictors, which means they squeeze their prey to suffocate them (not unlike Latvian people when you failed their school project). Pythons are fascinating creatures known for their incredible strength, diverse sizes, and beautiful patterns. Some say they look like big pastas, alive.</p>
<p>On this website, we explore the world of pythons, delving into the lives of these remarkable reptiles. We cover various species, their natural habitats, behaviors, and the conservation efforts to protect them.</p>
</section>
<section>
<h2>Discover the Species</h2>
<p>There are many species of pythons, each with its unique characteristics and beauty. From the reticulated python, which is the longest snake in the world, to the smaller ball python, known for its calm demeanor and striking patterns. Join us as we explore these incredible species in detail.</p>
</section>
<figure>
<img src="placeholder-image-url.jpg" alt="A beautiful python" width="500">
<figcaption>A majestic python in its natural habitat.</figcaption>
</figure>

<nav>
<div class="container">
<a href="/www.python_site.com/cgi-bin/index.py">Python Site</a>
<a href="/development_site/cgi-bin/hello_py.cgi">Development Site</a>
<a href="/perl_site/index.html">Perl Site</a>
<a href="/php_site/index.html">PHP Site</a>
<a href="/www.python_site.com/index.html">Python Site</a>
</div>


</main>
<footer>
<p>&copy; 2024 Planet Python. All rights reserved.</p>
</footer>
</nav>
<div class="container">
<article>
<h2>About This Server</h2>
<p>Welcome to our multi-faceted web server. Here, you can find a variety of web applications and sites ranging from development tools to language-specific sites. Whether you're here to explore our Perl, PHP, or Python projects, or to delve into our development tools, there's something for everyone.</p>
<p>Please use the navigation above to explore our sites.</p>
</article>
</div>
<form action="/" method="post" enctype="multipart/form-data">
<label for="file">Choose a file:</label>
<input type="file" id="file" name="file">
<br>
<input type="submit" value="Upload">
</form>
<h2>Upload Multiple Files</h2>
<form action="/" method="post" enctype="multipart/form-data">
<input type="file" name="files[]" multiple>
<br>
<input type="submit" value="Upload Files">
</form>
</body>
</html>
3 changes: 1 addition & 2 deletions var/www.saladbook.xyz/database/database.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"Stefano": "Carrot",
"Leo": "nicoise",
"Daniil": "with_beets",
"Jane": "Caesar"
"Daniil": "with_beets"
}

0 comments on commit d8bbf38

Please sign in to comment.