|
@@ -2,10 +2,15 @@ Some tests building a simple API that determines whether an input string contain
|
|
|
|
|
|
# Bash (CGI) version
|
|
# Bash (CGI) version
|
|
|
|
|
|
|
|
+-----
|
|
|
|
+
|
|
### Check if POST'd string contains all lowercase letters of the latin alphabet
|
|
### Check if POST'd string contains all lowercase letters of the latin alphabet
|
|
**URL:** '/contains_all_chars.sh'
|
|
**URL:** '/contains_all_chars.sh'
|
|
|
|
+
|
|
**Method:** POST
|
|
**Method:** POST
|
|
|
|
+
|
|
**Data params:** Plain text
|
|
**Data params:** Plain text
|
|
|
|
+
|
|
**Details:** Removes all non-interesting characters, sorts remaining characters, removes duplicates. Checks that the length of the result matches the length of the characters we wanted.
|
|
**Details:** Removes all non-interesting characters, sorts remaining characters, removes duplicates. Checks that the length of the result matches the length of the characters we wanted.
|
|
|
|
|
|
**Example response:**
|
|
**Example response:**
|
|
@@ -24,16 +29,24 @@ Some tests building a simple API that determines whether an input string contain
|
|
{"error": null, "result": false}
|
|
{"error": null, "result": false}
|
|
|
|
|
|
# Hitting API endpoint with GET method
|
|
# Hitting API endpoint with GET method
|
|
-[jceresini@slartibartfast ~]$ curl http://test.ceresini.com/contains_all_chars.sh
|
|
|
|
|
|
+a[jceresini@slartibartfast ~]$ curl http://test.ceresini.com/contains_all_chars.sh
|
|
{"error": "Invalid http method", "result": null}
|
|
{"error": "Invalid http method", "result": null}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+-----
|
|
|
|
+-----
|
|
|
|
+
|
|
# Python version using Flask
|
|
# Python version using Flask
|
|
|
|
|
|
|
|
+-----
|
|
|
|
+
|
|
### Check if POST'd string contains all lowercase letters of the latin alphabet: Method A
|
|
### Check if POST'd string contains all lowercase letters of the latin alphabet: Method A
|
|
**URL:** '/contains_all_chars_a'
|
|
**URL:** '/contains_all_chars_a'
|
|
|
|
+
|
|
**Method:** POST
|
|
**Method:** POST
|
|
|
|
+
|
|
**Data params:** Plain text
|
|
**Data params:** Plain text
|
|
|
|
+
|
|
**Details:** Uses python's built-in [set].issubset function to see if the set of lowercase latin alphabet characters is a subset of the posted data
|
|
**Details:** Uses python's built-in [set].issubset function to see if the set of lowercase latin alphabet characters is a subset of the posted data
|
|
|
|
|
|
**Example response:**
|
|
**Example response:**
|
|
@@ -53,10 +66,15 @@ Some tests building a simple API that determines whether an input string contain
|
|
{"result": false, "error": null}
|
|
{"result": false, "error": null}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+-----
|
|
|
|
+
|
|
### Check if POST'd string contains all lowercase letters of the latin alphabet: Method B
|
|
### Check if POST'd string contains all lowercase letters of the latin alphabet: Method B
|
|
**URL:** '/contains_all_chars_a'
|
|
**URL:** '/contains_all_chars_a'
|
|
|
|
+
|
|
**Method:** POST
|
|
**Method:** POST
|
|
|
|
+
|
|
**Data params:** Plain text
|
|
**Data params:** Plain text
|
|
|
|
+
|
|
**Details:** Interates over each character of the posted data to see if it contains each lowercase character in the latin alphabet. Returns as soon as it has seen each character once.
|
|
**Details:** Interates over each character of the posted data to see if it contains each lowercase character in the latin alphabet. Returns as soon as it has seen each character once.
|
|
|
|
|
|
**Example response:**
|
|
**Example response:**
|