├── 0-shell ├── cd.md ├── cp.md ├── cat.md ├── echo.md ├── mkdir.md ├── command-parsing.md ├── ls.md ├── rm.md └── mv.md ├── real-time-form ├── backend.md ├── websocket.md └── spa.md ├── forum ├── style.md └── requests.md ├── lem-in ├── hi.zip └── bzaf.zip ├── groupie-tracker ├── geolocation.md ├── visualilze.md ├── search.md └── filter.md ├── graphql └── authorization.md ├── push-swap ├── file.md └── randomNumbers.go ├── math-skills ├── unit-testing │ ├── README.md │ └── math_skill_test.go ├── README.md └── main_test.go ├── linear-stats ├── README.md └── main_test.go ├── go-reloaded ├── go-reloaded.md ├── ranniz ├── result.md └── sample.md ├── lets-play ├── error_handling.md ├── security.md ├── authentication_handling.md └── functional_tests.md ├── README.md ├── ascii-art ├── normal.md └── fs.md └── 01Blog └── exceptions.md /0-shell/cd.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /0-shell/cp.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /0-shell/cat.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /0-shell/echo.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /0-shell/mkdir.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /0-shell/command-parsing.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /real-time-form/backend.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /forum/style.md: -------------------------------------------------------------------------------- 1 | 1- check responsive design 2 | -------------------------------------------------------------------------------- /lem-in/hi.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmaach/01edu-tests/HEAD/lem-in/hi.zip -------------------------------------------------------------------------------- /lem-in/bzaf.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmaach/01edu-tests/HEAD/lem-in/bzaf.zip -------------------------------------------------------------------------------- /real-time-form/websocket.md: -------------------------------------------------------------------------------- 1 | - try to connect to the websocket from an external script (check authorisations) -------------------------------------------------------------------------------- /groupie-tracker/geolocation.md: -------------------------------------------------------------------------------- 1 | check if the location are correct (this is important) 2 | 3 | the geocoding must be writting with golang 4 | 5 | if the details artist take time failed -------------------------------------------------------------------------------- /graphql/authorization.md: -------------------------------------------------------------------------------- 1 | - if the token is stored in the local storage: 2 | - try to modify it. 3 | - then try delete it. 4 | - login with an account with no data (pooler) 5 | 6 | -------------------------------------------------------------------------------- /groupie-tracker/visualilze.md: -------------------------------------------------------------------------------- 1 | same background for all pages 2 | 3 | the instructure of the site is clear 4 | 5 | the user is not allowed to access the style or js or images if exists 6 | 7 | -------------------------------------------------------------------------------- /real-time-form/spa.md: -------------------------------------------------------------------------------- 1 | - try inter an undefined route, then is ther a buton to return to the home page without refreshing 2 | - if the token is stored in the local storage: 3 | - try to modify it. 4 | - then try delete it. 5 | -------------------------------------------------------------------------------- /push-swap/file.md: -------------------------------------------------------------------------------- 1 | try to put a numbers sorted desc 2 | 3 | try to put numbers asc 4 | 5 | try to put char with those numbers 6 | 7 | try to put empty stack 8 | 9 | try to put desc numbers with length bigger than 5 10 | 11 | ask about the algorithm 12 | 13 | ask about memory 14 | 15 | -------------------------------------------------------------------------------- /groupie-tracker/search.md: -------------------------------------------------------------------------------- 1 | no duplication in the search suggestions 2 | 3 | no duplication in the display of artist when the user search 4 | 5 | the input must be required or when the user search an empty string display all artists 6 | 7 | check the length of the input incase the entity is too large 8 | 9 | -------------------------------------------------------------------------------- /math-skills/unit-testing/README.md: -------------------------------------------------------------------------------- 1 | This it a unit testing based math-skills test that tries the output for 10000 times (default) you can increase it. 2 | 3 | 4 | ### Usage 5 | In your project base add this: 6 | ```go 7 | curl -O "https://raw.githubusercontent.com/lfarssi/01edu-tests/main/math-skills/unit-testing/math_skill_test.go" 8 | go test -v 9 | ``` -------------------------------------------------------------------------------- /linear-stats/README.md: -------------------------------------------------------------------------------- 1 | Hello my friend 2 | Requirements 3 | ``` 4 | golang (tested 1.22.3) 5 | brain (optional) 6 | some software to unzip (tested unzip 6.0) 7 | ``` 8 | setup 9 | ``` 10 | curl -O https://assets.01-edu.org/stats-projects/stat-bin-dockerized.zip 11 | unzip stat-bin-dockerized.zip 12 | ./stat-bin/bin/linear-stats 13 | go run . data.txt 14 | ``` 15 | good luck ;) -------------------------------------------------------------------------------- /math-skills/README.md: -------------------------------------------------------------------------------- 1 | Hello my friend 2 | Requirements 3 | ``` 4 | golang (tested 1.22.3) 5 | brain (optional) 6 | some software to unzip (tested unzip 6.0) 7 | ``` 8 | setup 9 | ``` 10 | curl -O https://assets.01-edu.org/stats-projects/stat-bin-dockerized.zip 11 | unzip stat-bin-dockerized.zip 12 | ./stat-bin/bin/linear-stats 13 | go run . data.txt 14 | ``` 15 | good luck ;) -------------------------------------------------------------------------------- /go-reloaded/go-reloaded.md: -------------------------------------------------------------------------------- 1 | (cap) 2 | (down) 3 | (up) 4 | (bin) 5 | (hex) 6 | hi (cap) (up, 2) how are u (up, 2) (dow ,2) today (cap, 2 ) 7 | 8 | 1000 (bin) (hex) 9 | 10 | fds, fdds,,,,, f fd,f, , ,fd,f,d f,d ff ' ' ' fdsfdfds ' fsf' fsd'e f df' fdfsd ' fds ' fsd' 11 | 12 | a hello a a a a a a aa a a a a a a a a a a a ana ana an aaa ba a an 13 | (up , 3) 14 | -------------------------------------------------------------------------------- /groupie-tracker/filter.md: -------------------------------------------------------------------------------- 1 | check if u can filter multiple times 2 | 3 | update the fillter query's and check if u can filter by a value gt 8 member or lt 1 member , also filter by a location doesn't exists 4 | 5 | check if u can filter by creation date from gt creation date to (also first album) this is an err 6 | 7 | is there's an input on filter fields check if there's suggestions 8 | 9 | if u don't filter and submit all artists display in the page 10 | 11 | -------------------------------------------------------------------------------- /lets-play/error_handling.md: -------------------------------------------------------------------------------- 1 | # **Error Handling Tests** 2 | 3 | ## **General Error Tests** 4 | 5 | 1. Ensure that requesting a non-existing user or product returns a `404 NOT_FOUND` error. 6 | 2. Ensure that validation errors (e.g., empty name, invalid email, invalid price) return a `400 BAD_REQUEST` error. 7 | 3. Ensure that unsupported HTTP methods (e.g., `PUT` on an endpoint that only accepts `GET`) return a `405 METHOD_NOT_ALLOWED` error. 8 | 4. Ensure that any unexpected exceptions return a `500 INTERNAL_SERVER_ERROR` with a generic error message. 9 | 10 | ## **Authorization & Access Denied** 11 | 12 | 5. Ensure that unauthorized actions trigger an `AccessDeniedException` with an appropriate error message when access is denied. 13 | -------------------------------------------------------------------------------- /math-skills/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os/exec" 6 | ) 7 | 8 | func main() { 9 | cmd1 := exec.Command("go", "build", "main.go") 10 | build, err := cmd1.CombinedOutput() 11 | if err != nil { 12 | fmt.Println("Error:", err) 13 | return 14 | } 15 | fmt.Println(build) 16 | for i := 0; i < 10000; i++ { 17 | cmd := exec.Command("bin/math-skills") 18 | output, err := cmd.CombinedOutput() 19 | if err != nil { 20 | fmt.Println("Error:", err) 21 | return 22 | } 23 | cmd1 := exec.Command("./main") 24 | output1, err := cmd1.CombinedOutput() 25 | if err != nil { 26 | fmt.Println("Error:", err) 27 | return 28 | } 29 | if string(output1) != string(output) { 30 | fmt.Println("Output does not match") 31 | fmt.Printf("o1:%s\ngo o2 :%s", output, output1) 32 | return 33 | } 34 | fmt.Printf("Test %d passed\n", i) 35 | } 36 | // Print the command's output 37 | fmt.Print("good\n") 38 | } 39 | -------------------------------------------------------------------------------- /math-skills/unit-testing/math_skill_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os/exec" 5 | "testing" 6 | ) 7 | 8 | func TestMathSkills(t *testing.T) { 9 | cmd1 := exec.Command("go", "build", "-o", "main", "main.go") 10 | build, err := cmd1.CombinedOutput() 11 | if err != nil { 12 | t.Fatalf("Build failed: %v\nOutput: %s", err, string(build)) 13 | } 14 | 15 | for i := 0; i < 1000; i++ { 16 | 17 | output1, err := exec.Command("bin/math-skills", "data.txt").CombinedOutput() 18 | if err != nil { 19 | t.Fatalf("Error running reference binary: %v\nOutput: %s", err, string(output1)) 20 | } 21 | 22 | output2, err := exec.Command("./main", "data.txt").CombinedOutput() 23 | if err != nil { 24 | t.Fatalf("Error running your program: %v\nOutput: %s", err, string(output2)) 25 | } 26 | 27 | if string(output1) != string(output2) { 28 | t.Errorf("Test %d failed: outputs don't match\nRef:\n%s\nYour:\n%s", i, string(output1), string(output2)) 29 | break 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /push-swap/randomNumbers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | "time" 7 | ) 8 | 9 | func generateUniqueRandomNumbers(n int) []int { 10 | // Create a map to store unique numbers 11 | arr := make(map[int]bool) 12 | rand.Seed(time.Now().UnixNano()) // Seed random number generator 13 | 14 | // Create a slice to hold the final result 15 | var result []int 16 | 17 | // Keep generating random numbers until we have 'n' unique numbers 18 | for len(arr) < n { 19 | num := rand.Int() // Generate a random number 20 | if !arr[num] { // Check if the number is unique 21 | arr[num] = true // Add to the map 22 | result = append(result, num) // Add to the result slice 23 | } 24 | } 25 | 26 | return result 27 | } 28 | 29 | func main() { 30 | // Generate 500 unique random numbers 31 | numbers := generateUniqueRandomNumbers(100) 32 | 33 | // Print the result 34 | for _, num := range numbers { 35 | fmt.Print(num, " ") 36 | } 37 | } -------------------------------------------------------------------------------- /go-reloaded/ranniz: -------------------------------------------------------------------------------- 1 | 1E (hex, 3) files were added to 10 (bin) folders 2 | (cap) This text has no modifications (up) (low) (cap) (hex) (bin) 3 | Let's test (up, 3) multiple spaces 4 | How about (low,0) zero or (up,-1) negative numbers? 5 | Nested modifications: (up, 2 (low, 1)) should this work? 6 | Incomplete modifiers: (up (low) ( 7 | Mixed case HEX: 1a3f (hex) should be converted 8 | A untold story about a hour and a herb 9 | Punctuation madness: What ?? !? ... ,. ; : ' test ' 's 10 | That's not how'quotes'work but'let's'see 11 | (up,9999) will this try to modify more words than exist? 12 | 1010101010101010101010101010 (bin) very long binary 13 | a e i o u h A E I O U H testing 'a' vs 'an' 14 | ' ' ' empty quotes 15 | ' multiple' ' wor'ds 'in quotes '. 16 | (cap, 2) at the end of a sentence. (up, 3) at the start of a sentence. 17 | This is so exciting (up, 2) ! 18 | Multiple. Sentences . With . Weird . Spacing . 19 | This text has (imaginary) modifiers (hello) (world) (up) 20 | ' "Don't outcome it it's a aaa a à éé é àà larm ' ' 21 | ' ' ' 22 | 😀gggggggggggggggg (cap) 23 | 😀gggggggggggggggg (up) 24 | 25 | fffffffffffffffffffffffffffffffffff (hex) 26 | 27 | hhhhh (up (down (up, 5))) -------------------------------------------------------------------------------- /linear-stats/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os/exec" 6 | "testing" 7 | ) 8 | 9 | func TestMain(t *testing.T) { 10 | // .exe for compatibility with windows linux ignores file extension for executables 11 | cmd1 := exec.Command("go", "build", "-o", "test.exe", ".") 12 | build, err := cmd1.CombinedOutput() 13 | if err != nil { 14 | fmt.Println("Error0:", err) 15 | return 16 | } 17 | fmt.Println(build) 18 | for i := 0; i < 50; i++ { 19 | cmd := exec.Command("stat-bin/bin/linear-stats") 20 | output, err := cmd.CombinedOutput() 21 | if err != nil { 22 | fmt.Println("Error1:", err) 23 | return 24 | } 25 | cmd1 := exec.Command("./test.exe", "data.txt") 26 | output1, err := cmd1.CombinedOutput() 27 | if err != nil { 28 | fmt.Println("Error2:", err) 29 | return 30 | } 31 | if string(output1) != string(output) { 32 | fmt.Println("Output does not match") 33 | fmt.Printf("o1:%s\ngo o2 :%s", output, output1) 34 | t.Fail() 35 | return 36 | } 37 | fmt.Printf("Test %d passed\n", i) 38 | } 39 | cmd3 := exec.Command("rm", "test.exe") 40 | _, err = cmd3.CombinedOutput() 41 | if err != nil { 42 | fmt.Println("Error:", err) 43 | return 44 | } 45 | // Print the command's output 46 | fmt.Print("done testing\n") 47 | } 48 | -------------------------------------------------------------------------------- /lets-play/security.md: -------------------------------------------------------------------------------- 1 | # **Security & Data Integrity Tests** 2 | 3 | ## **Password and Sensitive Data Handling** 4 | 5 | 1. Ensure that passwords stored in the database are hashed and cannot be retrieved as plain text. 6 | 2. Ensure that sensitive fields, like passwords, are never exposed in the `/api/users` response. 7 | 8 | ## **Input Validation and Sanitization** 9 | 10 | 3. Ensure that user inputs (e.g., name, email) are sanitized to prevent script injections. 11 | 4. Ensure that product inputs (e.g., name, description) are sanitized to prevent script injections. 12 | 13 | ## **Database Integrity** 14 | 15 | 5. Ensure that the database prevents duplicate product IDs. 16 | 6. Ensure that simultaneous creation of multiple users is thread-safe. 17 | 7. Ensure that simultaneous creation of multiple products for the same user is handled correctly. 18 | 19 | ## **Token and Session Management** 20 | 21 | 8. Ensure that tokens are invalidated after user deletion. 22 | 9. Ensure that token refresh or re-login behavior works correctly after a password change. 23 | 24 | ## **User and Product Updates** 25 | 26 | 10. Ensure that the `PATCH /api/me` endpoint only updates the fields provided in the request, leaving others intact. 27 | 11. Ensure that `DELETE /api/me` deletes the user’s associated products (if cascading deletion is implemented). 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 01 Edu Project Tests Repository 2 | 3 | ## Overview 4 | 5 | This repository contains test cases for various 01 Edu projects. Each project has its own dedicated folder with text files representing different test scenarios. 6 | 7 | ## Repository Structure 8 | 9 | ``` 10 | 01edu-tests/ 11 | │ 12 | ├── project1/ 13 | │ ├── test_case1.txt 14 | │ ├── test_case2.txt 15 | │ └── test_case3.txt 16 | │ 17 | ├── project2/ 18 | │ ├── test_case1.txt 19 | │ └── test_case2.txt 20 | │ 21 | └── README.md 22 | ``` 23 | 24 | ## How to Use the Tests 25 | 26 | ### Test File Naming Convention 27 | 28 | - Each test file is named descriptively to indicate the specific scenario being tested. 29 | - Files are plain text (.txt) for easy readability. 30 | 31 | ### Running Tests 32 | 33 | 1. Navigate to the specific project folder you want to test. 34 | 2. Review the test case files to understand the different scenarios. 35 | 3. Use these test files as a reference or input for your project implementations. 36 | 37 | ## Contributing 38 | 39 | ### Adding New Tests 40 | 41 | 1. Create a folder for a new project if it doesn't exist. 42 | 2. Add test case files with clear and descriptive names. 43 | 3. Ensure test cases cover various scenarios and edge cases. 44 | 45 | ## Notes 46 | 47 | - Test files are meant to be used as guidance and reference. 48 | - Always verify and validate tests against the specific project requirements. 49 | -------------------------------------------------------------------------------- /0-shell/ls.md: -------------------------------------------------------------------------------- 1 | # LS Command Tests 2 | 3 | ## Basic listing 4 | - `ls` 5 | ✅ Lists non-hidden files/directories in the current directory. 6 | 7 | ## Flag: `-a` (all) 8 | - `ls -a` 9 | ✅ Includes `.` and `..` as well as hidden files (starting with `.`). 10 | 11 | ## Flag: `-l` (long listing) 12 | - `ls -l` 13 | ✅ Displays permissions, links, owner, group, size, modified time, and name. 14 | 15 | ## Flag: `-F` (classify) 16 | - `ls -F` 17 | ✅ Appends `/` to directories, `*` to executables, etc. (only `/` implemented). 18 | 19 | ## Combined flags 20 | - `ls -la` 21 | ✅ Long listing including hidden files. 22 | 23 | - `ls -al` 24 | ✅ Same as `-la`. 25 | 26 | - `ls -lF` 27 | ✅ Long listing with directory indicators. 28 | 29 | - `ls -Fl` 30 | ✅ Same as `-lF`. 31 | 32 | - `ls -aF` 33 | ✅ All files (including hidden), with `/` for directories. 34 | 35 | - `ls -Fa` 36 | ✅ Same as `-aF`. 37 | 38 | - `ls -laF`, `ls -lFa`, `ls -alF`, etc. 39 | ✅ Long listing, hidden files, and directory slashes. 40 | 41 | ## Error cases 42 | - `ls invalid.txt` 43 | ❌ Returns error: no path arguments allowed (if not supported). 44 | 45 | - `ls --help` 46 | ❌ Returns error (if not supported). 47 | 48 | - `ls -z` 49 | ❌ Returns: Invalid flag. 50 | 51 | - `ls -alZ` 52 | ❌ Returns: Invalid flag `Z`. 53 | 54 | ## Special entries 55 | - `ls -a` 56 | ✅ Must include `.` and `..`. 57 | 58 | - `ls -alF` 59 | ✅ `.` and `..` should appear with full metadata and `/`. 60 | -------------------------------------------------------------------------------- /lets-play/authentication_handling.md: -------------------------------------------------------------------------------- 1 | # **Authentication & Authorization Tests** 2 | 3 | ## **Unauthenticated Access Tests** 4 | 5 | 1. Ensure that unauthenticated users cannot access the `/api/admin/users` endpoint. 6 | 2. Ensure that normal users cannot access endpoints reserved for Admins. 7 | 3. Ensure that users cannot access the `/api/me` endpoint without a valid token (returns `401 UNAUTHORIZED`). 8 | 9 | ## **Admin Access Tests** 10 | 11 | 4. Ensure that Admins can update and delete any user or product. 12 | 5. Ensure that Admins can successfully update another user’s role. 13 | 6. Ensure that Admins cannot assign an invalid role when updating a user. 14 | 15 | ## **User Access Tests** 16 | 17 | 7. Ensure that users can only update or delete their own products. 18 | 8. Ensure that users cannot update another user's profile (returns `403 FORBIDDEN`). 19 | 9. Ensure that users cannot delete another user's product (returns `403 FORBIDDEN`). 20 | 10. Ensure that users cannot access `/api/admin/users` with a regular user token (returns `403 FORBIDDEN`). 21 | 22 | ## **Authentication Tests** 23 | 24 | 11. Ensure that logging in with an unregistered email returns `400 BAD_REQUEST`. 25 | 12. Ensure that logging in with a correct email but an incorrect password returns `400 BAD_REQUEST`. 26 | 13. Ensure that a user with an expired or malformed JWT token gets `401 UNAUTHORIZED`. 27 | 14. Ensure that users can access the `GET /api/products` endpoint without a token (since it's publicly accessible). 28 | 15. Ensure that access to `/api/products` is still allowed with an invalid token, since it is a public endpoint. 29 | -------------------------------------------------------------------------------- /0-shell/rm.md: -------------------------------------------------------------------------------- 1 | ### 1. **Delete the current directory** 2 | 3 | ```bash 4 | rm -r . 5 | ``` 6 | ### 1. **Delete the current directory** 7 | 8 | ```bash 9 | rm -r . 10 | # ⚠️ Dangerous: may delete all contents of the current directory if not protected 11 | # Recommended: refuse this or warn strongly 12 | ``` 13 | 14 | --- 15 | 16 | ### 2. **Refuse to remove parent directory** 17 | 18 | ```bash 19 | rm -r .. 20 | # ❌ Refused: rm should never allow removing '..' 21 | # Output: rm: refusing to remove '.' or '..' directory: skipping '..' 22 | ``` 23 | 24 | --- 25 | 26 | ### 3. **Refuse to remove '.' and '..' in relative form** 27 | 28 | ```bash 29 | rm -r ./. 30 | rm -r ./.. 31 | rm -r ././. 32 | # ❌ Refused: these are equivalent to '.' and '..' 33 | # Output: rm: refusing to remove '.' or '..' directory: skipping './.' 34 | ``` 35 | 36 | --- 37 | 38 | ### 4. **Refuse to remove root directory** 39 | 40 | ```bash 41 | rm -r / 42 | # ❌ Refused: dangerous 43 | # Output: rm: it is dangerous to operate recursively on '/' 44 | ``` 45 | 46 | --- 47 | 48 | ### 5. **Try to remove a non-existent file** 49 | 50 | ```bash 51 | rm -r no_such_file 52 | # ❌ Error: No such file or directory 53 | ``` 54 | 55 | --- 56 | 57 | ### 6. **Try to remove a file (not a directory)** 58 | 59 | ```bash 60 | touch file 61 | rm -r file 62 | # ✅ Should work even without `-r` if file 63 | ``` 64 | 65 | --- 66 | 67 | ### 7. **Try to remove a non-empty directory** 68 | 69 | ```bash 70 | mkdir dir 71 | touch dir/file 72 | rm -r dir 73 | # ✅ Works: removes dir and its contents 74 | ``` 75 | 76 | --- 77 | 78 | ### 8. **Try to remove multiple valid files and directories** 79 | 80 | ```bash 81 | touch a b 82 | mkdir c && touch c/file 83 | rm -r a b c 84 | # ✅ Works: removes a, b, and directory c with its contents 85 | ``` 86 | 87 | --- 88 | 89 | ### 9. **Refuse to remove '.' or '..' mixed with valid files** 90 | 91 | ```bash 92 | touch file 93 | rm -r . file 94 | # ❌ Refuse `.` but still remove `file` 95 | # Output: rm: refusing to remove '.' or '..' directory: skipping '.' 96 | ``` 97 | 98 | --- 99 | 100 | ### 10. **Refuse to remove symlink to `/` or parent** 101 | 102 | ```bash 103 | ln -s / symlink_to_root 104 | ln -s .. symlink_to_parent 105 | rm -r symlink_to_root symlink_to_parent 106 | # ✅ Symlinks themselves can be deleted — this is allowed 107 | # ⚠️ But don't follow them recursively 108 | ``` 109 | 110 | 111 | -------------------------------------------------------------------------------- /ascii-art/normal.md: -------------------------------------------------------------------------------- 1 | this is test for the project ascii art the normal version 2 | 3 | to verifier your project try to run this test 4 | 5 | this ones are error and it must be handled 6 | Missing argument (should produce an error) 7 | go run . 8 | 9 | Multiple arguments (should produce an error) 10 | go run . "test" "test" 11 | 12 | Examples with characters below ASCII 32 13 | go run . "Hello" # Backspace (ASCII 8) 14 | go run . "Text with a tab " # Tab (ASCII 9) 15 | go run . "Line\nBreak" # Newline (ASCII 10) 16 | 17 | Examples with characters above ASCII 126 18 | go run . "Helloÿ" # 'ÿ' (ASCII 255) 19 | go run . "Testé" # 'é' (ASCII 233) 20 | go run . "Invalid√π" # √ and π are outside 126 21 | go run . "Symbols¿¡§" 22 | //////////////////////////// 23 | this tests must run without crashing or any error 24 | ///////////////////////// 25 | go run . "" 26 | go run . "123\n\n\n\n" 27 | go run . " \n " 28 | go run . " !\"#$%&'()*+,-./" 29 | go run . "0123456789:;<=>?" 30 | go run . "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" 31 | go run . "abcdefghijklmnopqrstuvwxyz{|}~" 32 | go run . "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 33 | go run . "0123456789" 34 | go run . "!@#$%^&*()_+-=[]{}|;':\",.<>/?" 35 | go run . "The quick brown fox jumps over the lazy dog!" 36 | go run . " Leading and trailing spaces " 37 | go run . "Hello\nWorld" 38 | go run . "Line1\nLine2\n\nLine4" 39 | go run . "12345\n67890\n!@#$%" 40 | go run . "Mixed symbols and numbers: @#$% 12345" 41 | go run . "Punctuation test: .,;:!?\"'`~" 42 | go run . "All uppercase: ABCDEFGHIJKLMNOPQRSTUVWXYZ" 43 | go run . "All lowercase: abcdefghijklmnopqrstuvwxyz" 44 | go run . "Special characters only: ~!@#$%^&*()-_=+[]{}|;:',.<>/?" 45 | go run . "12345 ABCDE abcde" 46 | go run . "This is a test of\nmultiple lines with spaces\nand tabs\tlike this." 47 | go run . "Complete ASCII range from 32 to 126:\n !\"#$%&'()*+, 48 | go run . "This\tis\tweird" 49 | 50 | //////////////////// 51 | this is new lines test 52 | /////////////////// 53 | go run . "Just a long string\nwith no specific\nstructure\nbut lots of lines" 54 | go run . "123\n\n\n\n" 55 | go run . " \n " 56 | go run . "Hello\nWorld" 57 | go run . "\nStart with a newline" 58 | go run . "End with a newline\n" 59 | go run . "Multiple\nnew\nlines\nin\none\ninput" 60 | go run . "Lines with spaces\n Line 2 with leading spaces\nLine 3\n" 61 | go run . "ASCII test\n !\"#$%&'()*+,-./0123456789:;<=>?\nABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n{|}~" 62 | -------------------------------------------------------------------------------- /lets-play/functional_tests.md: -------------------------------------------------------------------------------- 1 | # **Functional Tests (Users & Products CRUD)** 2 | 3 | ## **Project Initialization & Basic API Operations** 4 | 5 | 1. Ensure the project starts without errors and responds to API requests. 6 | 7 | ## **User Authentication and Registration** 8 | 9 | 2. Ensure that `POST /api/auth/register` creates a new user with valid data. 10 | 3. Ensure that `POST /api/auth/register` fails with an invalid email format. 11 | 4. Ensure that `POST /api/auth/login` returns a token for valid credentials. 12 | 5. Ensure that `POST /api/auth/login` fails with incorrect credentials. 13 | 14 | ## **Admin Operations on Users** 15 | 16 | 6. Ensure that `GET /api/admin/users` returns a list of users for an Admin. 17 | 7. Ensure that `GET /api/admin/users/{id}` returns the correct user by ID. 18 | 8. Ensure that `POST /api/admin/users` creates a new user (Admin only). 19 | 9. Ensure that `PATCH /api/admin/users/{id}` updates a user’s data correctly (Admin only). 20 | 10. Ensure that `DELETE /api/admin/users/{id}` deletes a user (Admin only). 21 | 22 | ## **Authenticated User Operations** 23 | 24 | 11. Ensure that `GET /api/me` returns the authenticated user's profile. 25 | 12. Ensure that `PATCH /api/me` updates the authenticated user's profile. 26 | 13. Ensure that `DELETE /api/me` deletes the authenticated user's profile. 27 | 28 | ## **Product Operations** 29 | 30 | 14. Ensure that `GET /api/products` returns all products without authentication. 31 | 15. Ensure that `GET /api/products/{id}` returns the correct product by ID. 32 | 16. Ensure that `GET /api/products/user` returns the products of the current authenticated user. 33 | 17. Ensure that `GET /api/products/user/{id}` returns products for a specific user ID. 34 | 18. Ensure that `POST /api/products` creates a product for the authenticated user. 35 | 19. Ensure that `PATCH /api/products/{id}` updates a product by its owner or Admin. 36 | 20. Ensure that `DELETE /api/products/{id}` deletes a product by its owner or Admin. 37 | 38 | ## **Validation and Error Handling** 39 | 40 | 21. Ensure that creating a user with an already registered email returns `400 BAD_REQUEST`. 41 | 22. Ensure that creating a product with missing required fields returns `400 BAD_REQUEST`. 42 | 23. Ensure that updating a non-existing user returns `404 NOT_FOUND`. 43 | 24. Ensure that updating a non-existing product returns `404 NOT_FOUND`. 44 | 25. Ensure that deleting a non-existing user returns `404 NOT_FOUND`. 45 | 26. Ensure that deleting a non-existing product returns `404 NOT_FOUND`. 46 | 27. Ensure that fetching a user with an invalid UUID format returns `400 BAD_REQUEST`. 47 | 28. Ensure that fetching a product with an invalid UUID format returns `400 BAD_REQUEST`. 48 | 29. Ensure that creating a product with a negative price returns `400 BAD_REQUEST`. 49 | 30. Ensure that creating a user with a password shorter than 6 characters returns `400 BAD_REQUEST`. 50 | 31. Ensure that updating a product with an empty name or description returns `400 BAD_REQUEST`. 51 | 32. Ensure that updating a user’s role with an invalid value returns `400 BAD_REQUEST`. 52 | 53 | ## **Empty Database and Multiple Records** 54 | 55 | 33. Ensure that listing products when the database is empty returns an empty array. 56 | 34. Ensure that listing users when the database is empty returns an empty array. 57 | 35. Ensure that multiple products can be created for the same user and retrieved correctly. -------------------------------------------------------------------------------- /go-reloaded/result.md: -------------------------------------------------------------------------------- 1 | If I make you breakfast in bed just say thank you instead of: How did you get in MY HOUSE? 2 | 3 | I have to pack 5 outfits. Packed 26 just to be sure 4 | 5 | Don not be sad, because sad backwards is das. And das not good 6 | 7 | Harold Wilson: 'I am an optimist, but an optimist who carries a raincoat.' 8 | 9 | 10 | 11 | John scored 30 points, while Jane scored 5 points in the game. 12 | The referee said: 'it was an intense match!' 13 | The fans shouted: WOW, THAT'S Incredible!! 14 | For dinner, we had an orange, an apple, and a huge pie. 15 | Punctuation must be correct... and consistent, right? 16 | The winner's speech: 'I am the best player in the world'!! 17 | 18 | 19 | 20 | an 26 spaceship crashed on an alien planet, and the pilot yelled: 'this is impossible!!' 21 | He then said: 'Contact the base immediately... we need help!!!' 22 | Meanwhile, a survivor found 42 files, a hologram, and a supercomputer. 23 | The message said: 'the system is critical: reboot now and initiate EMERGENCY PROTOCOLS!!!?' 24 | An observer stated: an unexpected object was spotted, it looked like a UFO. 25 | Punctuation needs fixing, don't you think? And what about groupings like... or!!? 26 | The report noted: 'It's a phenomenon of the century, we must act fast.' 27 | 28 | 29 | an 47 robot said: 'we have achieved THE IMPOSSIBLE!!?' 30 | Then it computed: 'Add 15 to 255 and multiply by 10.' 31 | an 42-year-old programmer thought, 'TIME TO DEBUG AND RELEASE the new software... or maybe not.' 32 | He exclaimed: 'This is it, a perfect solution!!' 33 | But the team noticed: an unexpected result, a division by zero, and another issue with the main function!! 34 | Meanwhile, the AI generated this sentence: 'I saw an Elephant Walking into a house... it was SURREAL AND AMAZING!' 35 | The punctuation tests are crucial, what do you think about... these complex challenges!!??? 36 | an advanced machine-learning model predicted that a UFO would appear near Area 51. 37 | 38 | 39 | 40 | 31 was found in the middle of the data set... but strangely 42 wasn't there!! 41 | The robot whispered: 'fix the uppercase errors quickly, and don't forget an amazing hack!' 42 | On the board, it was written: 'Multiply 250 by 10 and add 30 to achieve greatness!' 43 | Meanwhile, a team of 66 developers tried to debug, an enormous system!!? 44 | In the corner, someone shouted: 'The bug is in line 162 or line 7!' 45 | The scientist observed: 'An alien spaceship... landed on earth, an hour ago!!' 46 | An unnoticed phenomenon, a swarm of UFOs, and an unexpected meteor shower were all captured by a Professional Observatory!!! 47 | Punctuation madness ensues,!! What,?? Are you ready...!! Or not???? 48 | Final note: a quick, brown fox jumped over the lazy dog. 49 | 50 | 51 | 52 | 53 | this is a test to push the boundaries of the program. 54 | The next line will cause trouble if not handled correctly. 55 | Watch out for indexing errors IN EDGE CASES! 56 | Lastly, here is a challenge: 31 and 2 and another. 57 | 58 | 59 | 60 | 61 | Start With Some Simple Text but then try to break things. 62 | Here's a tricky one: what happens when 31 or 2? 63 | And let's mix things up: a SUPER-LONG-SERIES of instructions where each number might trigger an index issue. 64 | Now here's something special: 'a improperly closed' and another improperly 'closed one'. 65 | Finally, what if a crazy punctuation sequence...!!? happens here? 66 | Combine it all and you'll surely get an error or crash. 67 | -------------------------------------------------------------------------------- /ascii-art/fs.md: -------------------------------------------------------------------------------- 1 | for this project its the continue of the last one so go to the previous 2 | project test and test it than come back here 3 | 4 | be careful the standard banner must be the default 5 | 6 | 7 | 8 | Default to the standard banner 9 | go run . "Hello" 10 | go run . "ASCII Art" 11 | go run . "1234567890" 12 | go run . "!@#$%^&*()" 13 | go run . "Lowercase letters" 14 | go run . "UPPERCASE TEXT" 15 | 16 | Explicitly specified banners 17 | go run . "ThinkerToy" thinkertoy 18 | go run . "Shadow Mode" shadow 19 | go run . "Hello World!" thinkertoy 20 | go run . "12345 & Symbols" shadow 21 | 22 | Edge cases with valid characters 23 | go run . " " standard 24 | go run . "Multi\nline\ntext" shadow 25 | go run . "Edge Case: Empty space" 26 | go run . "LongTextWithoutSpaces" 27 | go run . "Tab Text Example" 28 | go run . "Boundary~`{|}[]Characters" thinkertoy 29 | go run . "abcdefghijklmnopqrstuvwxyz" standard 30 | go run . "ABCDEFGHIJKLMNOPQRSTUVWXYZ" thinkertoy 31 | go run . "Mix123! ABC" shadow 32 | go run . "Another Test" standard 33 | go run . "Hello\nWorld" standard # Valid: Multi-line text with a newline 34 | go run . "Line1\nLine2\nLine3" thinkertoy # Valid: Multiple lines 35 | go run . "\nHello" shadow # Valid: Starts with a newline 36 | go run . "Hello\n" standard # Valid: Ends with a newline 37 | go run . "Middle\nof\nText" thinkertoy # Valid: Multiple newlines in the middle 38 | go run . "ASCII\nArt" shadow # Valid: Text with a newline 39 | go run . "123\n456\n7890" # Valid: Numbers with newlines, default banner 40 | go run . "Special\nCharacters\n!@#" standard # Valid: Mixed special characters and newlines 41 | go run . "Single\n" thinkertoy # Valid: Single word followed by newline 42 | go run . "New\n\nLine" shadow # Valid: Two consecutive newlines in text 43 | go run . "\n\n" standard # Valid: Only newlines 44 | go run . "Test\n\nCase" thinkertoy # Valid: Mixed text and double newlines 45 | go run . "\n\n\n" shadow # Valid: Three newlines in input 46 | go run . "Valid\nText\nHere" # Valid: Newlines between words, default banner 47 | go run . "End with newline\n" standard # Valid: Ends with a newline character 48 | go run . "\nStart with newline" thinkertoy # Valid: Starts with a newline character 49 | go run . "Multi-line\nInput" shadow # Valid: Two-line input 50 | go run . "Spaced\n Text" standard # Valid: Newline followed by spaces 51 | go run . "Tabs\n\tText" thinkertoy # Valid: Tab following a newline 52 | go run . "Complex\n\nTest\nCase" shadow # Valid: Multiple newlines and mixed content 53 | 54 | 55 | # Missing input 56 | go run . # Error: Missing input text 57 | 58 | # Too many arguments 59 | go run . "Hello" standard shadow # Error: Too many arguments 60 | go run . "Test" shadow thinkertoy # Error: Too many arguments 61 | 62 | # Invalid banner 63 | go run . "Hello" invalidbanner # Error: Invalid banner specified 64 | go run . "Test123" 123 # Error: Invalid banner specified 65 | 66 | 67 | # Out-of-range characters 68 | go run . "Invalidÿ" shadow # Error: Contains out-of-range characters 69 | go run . "Textë" thinkertoy # Error: Contains out-of-range characters 70 | go run . "Hello€" standard # Error: Contains out-of-range characters 71 | go run . "Test💖" shadow # Error: Emoji or unsupported Unicode 72 | go run . "Text with extra "args"" 73 | go run . "Valid" "" 74 | 75 | 76 | -------------------------------------------------------------------------------- /go-reloaded/sample.md: -------------------------------------------------------------------------------- 1 | In a file called sample.txt, place the following text: If I make you BREAKFAST IN BED (low, 3) just say thank you instead of: how (cap) did you get in my house (up, 2) ? 2 | 3 | In a file called sample.txt place the following text: I have to pack 101 (bin) outfits. Packed 1a (hex) just to be sure 4 | 5 | n a file called sample.txt place the following text: Don not be sad ,because sad backwards is das . And das not good 6 | 7 | In a file called sample.txt place the following text: harold wilson (cap, 2) : ' I am a optimist ,but a optimist who carries a raincoat . ' 8 | 9 | 10 | 11 | 12 | John scored 1E (hex) points, while Jane scored 101 (bin) points in the game. 13 | The referee said: ' It was an intense match !' (low) 14 | The fans shouted: WOW (up, 2) , that's incredible (cap, 3) !! 15 | For dinner, we had A orange, a apple, and a huge pie. 16 | Punctuation must be correct ...and consistent ,right? 17 | The winner's speech: ' I am the best player in the world ' (cap, 6) !! 18 | 19 | 20 | 21 | a 1A (hex) spaceship crashed on an alien (low, 2) planet , and the pilot yelled: ' THIS IS IMPOSSIBLE !! ' 22 | He then said: ' Contact (cap) the base immediately (low, 3) ... we need help !!! ' 23 | Meanwhile, a survivor found 101010 (bin) files ,a hologram , and a supercomputer . 24 | The message said: 'the system is critical: reboot NOW (low) and initiate (up, 3) emergency protocols !!! ?' 25 | An observer stated: A unexpected object was spotted ,it looked like A UFO. 26 | Punctuation needs fixing ,don't you think? And what about groupings like ... or !!? 27 | The report noted: 'It's a phenomenon of the century , we must act fast .' (cap, 10) 28 | 29 | 30 | a 2F (hex) robot said: 'we (low, 3) have achieved (up, 2) the IMPOSSIBLE !! ?' 31 | Then it computed: 'add 1111 (bin) to FF (hex) and multiply by 1010 (bin) (cap)'. 32 | a 42-year-old programmer thought , 'time to debug (up, 3) and release the NEW (low) software' ... or maybe not . 33 | He exclaimed: 'THIS is it ,A perfect solution !!' 34 | But the team noticed: a unexpected result ,a division by zero ,and another issue with (low, 4) the MAIN FUNCTION !! 35 | Meanwhile, the AI generated this sentence: 'I saw an elephant (cap, 2) walking into A (low, 3) house (low, 2) ... it was surreal (up, 4)'. 36 | The punctuation tests are crucial , what do you think about ... these complex challenges !! ??? 37 | a advanced machine-learning (low, 5) model predicted that A UFO would appear near Area 51. 38 | 39 | 40 | 41 | 42 | 1F (hex) was found in the middle of the data set ... but strangely 101010 (bin) wasn't there !! 43 | The robot whispered: 'fix (low, 5) the UPPERCASE (up) errors QUICKLY ,and don't forget A amazing hack!' 44 | On the board, it was written: 'Multiply FA (hex) by 1010 (bin) and add 1E (hex) (cap, 7)'. 45 | Meanwhile, a team of 42 (hex) developers tried to debug ,an enormous (low, 3) SYSTEM !!? 46 | In the corner, someone shouted: 'THE BUG IS IN LINE A2 (hex) OR LINE 111 (bin) !' 47 | The scientist observed: 'an alien spaceship ... landed on earth , a hour ago!!' 48 | a unnoticed phenomenon ,a swarm of UFOs, and a unexpected meteor shower were all captured by a (cap, 6) observatory (low) !!! 49 | Punctuation madness ensues ,!! What , ?? Are you ready ...!! Or not ???? 50 | Final note: a (low, 4) quick , BROWN FOX JUMPED (up, 3) over the lazy dog. 51 | 52 | 53 | 54 | This is a (low, 1000) test to push the boundaries of the program. 55 | The next line will cause trouble (cap, 5000) if not handled correctly. 56 | Watch out for indexing errors (up, 3000) in edge cases! 57 | Lastly, here is a challenge: 1F (hex) and 10 (bin) and another (low, -1). 58 | 59 | 60 | 61 | Start with some simple text (cap, 2) but then try (cap, 10000 nested text (low, 500)) to break things. 62 | Here's a tricky one: what happens when (hex) has 1F (hex, 10000) or 1010 (bin, -10)? 63 | And let's mix things up: A super-long-series (up, 300) of instructions where each number (cap) might trigger an index issue (low, 50). 64 | Now here's something special: a improperly closed ' quote and another improperly ' closed one. 65 | Finally, what if a crazy punctuation sequence ...!!? happens here? 66 | Combine it all (low, 99999999) and you'll surely get (cap, -99999) an error or crash. 67 | -------------------------------------------------------------------------------- /01Blog/exceptions.md: -------------------------------------------------------------------------------- 1 | # **Global Exception Handler Tests** 2 | 3 | ## **Custom Exceptions** 4 | 5 | ### 1. **BaseException Tests** 6 | - **Test**: Ensure that when a `BaseException` is thrown, the API returns the correct status and error message. 7 | - **Expected Result**: The response status should match the exception's status and the response body should include the error code and message. 8 | 9 | --- 10 | 11 | ## **Security Exceptions** 12 | 13 | ### 2. **AccessDeniedException Tests** 14 | - **Test**: Ensure that when an `AccessDeniedException` is thrown, the API returns a `403 Forbidden` status and an appropriate error message. 15 | - **Expected Result**: The response status should be `403 FORBIDDEN`, and the message should be `"Access is denied"`. 16 | 17 | ### 3. **BadCredentialsException Tests** 18 | - **Test**: Ensure that when a `BadCredentialsException` is thrown, the API returns a `400 Bad Request` status with a relevant error message. 19 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should be `"Invalid email or password"`. 20 | 21 | --- 22 | 23 | ## **Validation & Parsing Exceptions** 24 | 25 | ### 4. **MethodArgumentNotValidException Tests** 26 | - **Test**: Ensure that when validation errors occur (via `MethodArgumentNotValidException`), the API returns a `400 Bad Request` with the specific validation error messages. 27 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should list the fields with validation errors. 28 | 29 | ### 5. **MethodArgumentTypeMismatchException Tests** 30 | - **Test**: Ensure that when a `MethodArgumentTypeMismatchException` is thrown, the API returns a `400 Bad Request` status with a specific error message related to the mismatched argument. 31 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should specify the invalid argument (e.g., "Invalid UUID format"). 32 | 33 | ### 6. **HttpMessageNotReadableException Tests** 34 | - **Test**: Ensure that when an `HttpMessageNotReadableException` is thrown, the API returns a `400 Bad Request` status with a message indicating invalid JSON format. 35 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should be `"Invalid JSON format"`. 36 | 37 | ### 7. **HttpMediaTypeNotSupportedException Tests** 38 | - **Test**: Ensure that when an `HttpMediaTypeNotSupportedException` is thrown, the API returns a `400 Bad Request` status with a message about unsupported media type. 39 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should be `"Unsupported media type"`. 40 | 41 | ### 8. **MissingServletRequestPartException Tests** 42 | - **Test**: Ensure that when a `MissingServletRequestPartException` is thrown (e.g., file not uploaded), the API returns a `400 Bad Request` status with a message indicating the missing file. 43 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should be `"File part is required but was not sent"`. 44 | 45 | --- 46 | 47 | ## **Request-Related Exceptions** 48 | 49 | ### 9. **NoHandlerFoundException Tests** 50 | - **Test**: Ensure that when a `NoHandlerFoundException` is thrown (i.e., no matching endpoint is found), the API returns a `404 Not Found` status with an appropriate error message. 51 | - **Expected Result**: The response status should be `404 NOT_FOUND`, and the message should be `"The endpoint does not exist"`. 52 | 53 | ### 10. **HttpRequestMethodNotSupportedException Tests** 54 | - **Test**: Ensure that when a `HttpRequestMethodNotSupportedException` is thrown (i.e., unsupported HTTP method is used), the API returns a `405 Method Not Allowed` status with an appropriate error message. 55 | - **Expected Result**: The response status should be `405 METHOD_NOT_ALLOWED`, and the message should specify the unsupported method (e.g., `"Method GET is not supported for this endpoint"`). 56 | 57 | ### 11. **MissingPathVariableException Tests** 58 | - **Test**: Ensure that when a `MissingPathVariableException` is thrown, the API returns a `400 Bad Request` status with a message indicating the missing path variable. 59 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should be `"Missing required path variable"`. 60 | 61 | ### 12. **MultipartException Tests** 62 | - **Test**: Ensure that when a `MultipartException` is thrown (i.e., incorrect multipart request format), the API returns a `400 Bad Request` status with a relevant error message. 63 | - **Expected Result**: The response status should be `400 BAD_REQUEST`, and the message should indicate an issue with the multipart/form-data request (e.g., `"Invalid multipart/form-data request: "`). 64 | 65 | ### 13. **MaxUploadSizeExceededException Tests** 66 | - **Test**: Ensure that when a `MaxUploadSizeExceededException` is thrown (i.e., file exceeds allowed size), the API returns a `413 Payload Too Large` status with a relevant error message. 67 | - **Expected Result**: The response status should be `413 PAYLOAD_TOO_LARGE`, and the message should include `"The uploaded file exceeds the maximum allowed size."`. 68 | 69 | ### 14. **NoSuchFileException Tests** 70 | - **Test**: Ensure that when a `NoSuchFileException` is thrown (i.e., requested file not found), the API returns a `404 Not Found` status with a relevant error message. 71 | - **Expected Result**: The response status should be `404 NOT_FOUND`, and the message should be `"Requested file not found"`. 72 | 73 | --- 74 | 75 | ## **Generic Exception** 76 | 77 | ### 15. **Generic Exception Tests** 78 | - **Test**: Ensure that when a generic `Exception` is thrown (uncaught exceptions), the API returns a `500 Internal Server Error` status with a relevant error message. 79 | - **Expected Result**: The response status should be `500 INTERNAL_SERVER_ERROR`, and the message should be `"Something went wrong. Please try again later."`. 80 | -------------------------------------------------------------------------------- /forum/requests.md: -------------------------------------------------------------------------------- 1 | # Forum - Security & Input Validation Test Suite 2 | 3 | This document outlines key test cases to ensure the Forum web application handles various types of HTTP requests and input sanitization correctly. 4 | 5 | --- 6 | 7 | ## ✅ 1. HTTP Method Validation 8 | 9 | | **Test Case** | **Description** | **Expected Result** | 10 | | --------------------------- | ----------------------- | --------------------------------------------- | 11 | | `GET` on `/api/post` | Fetch all posts | `200 OK` | 12 | | `POST` on `/api/post` | Create a new post | `201 Created` | 13 | | `PUT` on `/api/post/:id` | Update an existing post | `200 OK` or `403 Forbidden` if not authorized | 14 | | `DELETE` on `/api/post/:id` | Delete post | `200 OK` or `403 Forbidden` | 15 | | `PATCH` on invalid endpoint | Try unsupported method | `405 Method Not Allowed` | 16 | | `OPTIONS` request | CORS preflight check | CORS headers returned | 17 | 18 | --- 19 | 20 | ## ✅ 2. HTML / JavaScript Injection 21 | 22 | | **Test Case** | **Payload** | **Expected Result** | 23 | | ----------------------------------------- | ----------------------------------------------- | ------------------------------------------------- | 24 | | Script in `username` | `` | The script must be sanitized and **not** executed | 25 | | JS in `input value` | `` | Script should be escaped as plain text | 26 | | Hidden tag in post body | `
Hidden
` | Should render as-is unless filtered | 27 | | `` in comment | XSS via image | JS should not execute, HTML must be encoded | 28 | 29 | --- 30 | 31 | ## ✅ 3. Missing Required Fields 32 | 33 | | **Test Case** | **Field Missing** | **Expected Result** | 34 | | ------------- | -------------------- | ---------------------------------------- | 35 | | Registration | No `email` | `400 Bad Request` with descriptive error | 36 | | Login | No `password` | `400 Bad Request` | 37 | | Create Post | No `title` or `body` | Reject with appropriate message | 38 | 39 | --- 40 | 41 | ## ✅ 4. Long or Malformed Field Content 42 | 43 | | **Test Case** | **Description** | **Expected Result** | 44 | | --------------------------- | ------------------------------- | ------------------------------------------------------------ | 45 | | Excessively long `username` | 10,000+ characters | Reject with `413 Payload Too Large` or validation error | 46 | | Long post content | >10MB post body | Should be limited to maximum length | 47 | | Special characters in input | e.g. emojis, control characters | Should be safely stored or rejected based on encoding policy | 48 | 49 | --- 50 | 51 | ## ✅ 5. Malformed or Unexpected Content-Type 52 | 53 | | **Content-Type** | **Payload Example** | **Expected Result** | 54 | | ----------------------------------- | ------------------------------------------------------------------------------- | -------------------------------------------- | 55 | | `application/json` | `{ "username": "", "email": "test@example.com" }` | Input must be sanitized, no script execution | 56 | | `text/html` | `` | Rejected unless HTML is explicitly expected | 57 | | `application/x-www-form-urlencoded` | `username=&email=test@example.com` | XSS should be prevented | 58 | 59 | --- 60 | 61 | ## ✅ 6. Additional Recommended Tests 62 | 63 | ### 🛡️ Authentication 64 | 65 | | **Test Case** | **Description** | **Expected Result** | 66 | | ------------------------------------ | ------------------- | ------------------- | 67 | | Access protected route without token | `/api/profile` | `401 Unauthorized` | 68 | | Expired token | JWT with past `exp` | `401 Unauthorized` | 69 | | Tampered token | Altered signature | `403 Forbidden` | 70 | 71 | --- 72 | 73 | ### 🔐 CSRF Protection 74 | 75 | | **Test Case** | **Attack Vector** | **Expected Result** | 76 | | --------------------------------- | ------------------------------ | --------------------------------------------------- | 77 | | Forged form submission | Hidden form from external site | Rejected if CSRF token is missing/invalid | 78 | | AJAX call from third-party origin | With credentials | Should be blocked by CORS policy or CSRF protection | 79 | 80 | --- 81 | 82 | ### 🕵️ Input Encoding Tests 83 | 84 | | **Input** | **Field** | **Expected Output** | 85 | | --------------------------------- | ------------ | -------------------------------------------------- | 86 | | `bold` | comment | Render as plain text or safe HTML | 87 | | `\u202E` (Right-to-Left override) | title | Should not alter UI or be stripped | 88 | | SQL payload `' OR 1=1 --` | login fields | Must **not** affect query logic (no SQL injection) | 89 | 90 | -------------------------------------------------------------------------------- /0-shell/mv.md: -------------------------------------------------------------------------------- 1 | ## ✅ BASIC FUNCTIONAL TESTS 2 | 3 | ### 1. **Rename a file** 4 | 5 | ```bash 6 | touch oldname.txt 7 | mv oldname.txt newname.txt 8 | ls newname.txt 9 | ``` 10 | 11 | ✅ *Should show `newname.txt`, and `oldname.txt` should be gone.* 12 | 13 | --- 14 | 15 | ### 2. **Move file into directory** 16 | 17 | ```bash 18 | mkdir mydir 19 | touch file1.txt 20 | mv file1.txt mydir/ 21 | ls mydir/ 22 | ``` 23 | 24 | ✅ *Should see `file1.txt` inside `mydir`* 25 | 26 | --- 27 | 28 | ### 3. **Move and rename file into a directory** 29 | 30 | ```bash 31 | mv mydir/file1.txt mydir/renamed.txt 32 | ls mydir/ 33 | ``` 34 | 35 | ✅ *Should see `renamed.txt`, and `file1.txt` should be gone* 36 | 37 | --- 38 | 39 | ### 4. **Rename a directory** 40 | 41 | ```bash 42 | mkdir olddir 43 | mv olddir newdir 44 | ls -d newdir 45 | ``` 46 | 47 | ✅ *Should see `newdir` and not `olddir`* 48 | 49 | --- 50 | 51 | ### 5. **Move directory into another directory** 52 | 53 | ```bash 54 | mkdir parent 55 | mv newdir parent/ 56 | ls parent/ 57 | ``` 58 | 59 | ✅ *Should see `newdir` inside `parent/`* 60 | 61 | --- 62 | 63 | ## ❌ ERROR TEST CASES (No flags) 64 | 65 | ### 6. **Move non-existent file** 66 | 67 | ```bash 68 | mv not_a_file.txt dest.txt 69 | ``` 70 | 71 | ❌ *Should show error: `No such file or directory`* 72 | 73 | --- 74 | 75 | ### 7. **Move into non-existent directory** 76 | 77 | ```bash 78 | touch temp.txt 79 | mv temp.txt nosuchdir/ 80 | ``` 81 | 82 | ❌ *Should show error: `No such file or directory`* 83 | 84 | --- 85 | 86 | ### 8. **Move file onto existing file (no overwrite handling)** 87 | 88 | ```bash 89 | echo "one" > file_a.txt 90 | echo "two" > file_b.txt 91 | mv file_a.txt file_b.txt 92 | cat file_b.txt 93 | ``` 94 | 95 | ⚠️ *In a basic implementation, this would overwrite silently. You should test whether the content is `"one"` now. If not, overwriting didn’t work.* 96 | 97 | --- 98 | 99 | ### 9. **Missing arguments** 100 | 101 | ```bash 102 | mv 103 | mv fileonly 104 | ``` 105 | 106 | ❌ *Should show: `missing operand` or `missing destination`* 107 | 108 | --- 109 | 110 | ## ⚠️ SPECIAL CASES 111 | 112 | ### 10. **Move multiple files (should fail in basic version)** 113 | 114 | ```bash 115 | touch a.txt b.txt 116 | mv a.txt b.txt newname.txt 117 | ``` 118 | 119 | ❌ *Should fail: too many arguments* 120 | 121 | --- 122 | 123 | ### 11. **Moving file with same source and destination** 124 | 125 | ```bash 126 | touch same.txt 127 | mv same.txt same.txt 128 | ``` 129 | 130 | ⚠️ *Should do nothing, or return: `file is the same`* 131 | 132 | --- 133 | 134 | ## 🔁 RENAMING & MOVING EDGE CASES 135 | 136 | ### 12. **Rename with spaces in the name** 137 | 138 | ```bash 139 | touch "file with space.txt" 140 | mv "file with space.txt" "renamed file.txt" 141 | ls "renamed file.txt" 142 | ``` 143 | 144 | ✅ *Should handle quotes properly and rename the file* 145 | 146 | --- 147 | 148 | ### 13. **Move to path ending with a slash but is not a dir** 149 | 150 | ```bash 151 | touch file.txt 152 | touch notadir 153 | mv file.txt notadir/ 154 | ``` 155 | 156 | ❌ *Should fail: "not a directory" (unless `notadir` is a directory)* 157 | 158 | --- 159 | 160 | ### 14. **Move directory over a file** 161 | 162 | ```bash 163 | mkdir dir1 164 | touch file.txt 165 | mv dir1 file.txt 166 | ``` 167 | 168 | ❌ *Should fail: cannot overwrite file with directory* 169 | 170 | --- 171 | 172 | ### 15. **Move file over a directory** 173 | 174 | ```bash 175 | touch file.txt 176 | mkdir dir1 177 | mv file.txt dir1 178 | ``` 179 | 180 | ✅ *Should move file into `dir1/`* 181 | 182 | --- 183 | 184 | ### 16. **Move directory into itself (indirectly)** 185 | 186 | ```bash 187 | mkdir -p a/b 188 | mv a a/b/ 189 | ``` 190 | 191 | ❌ *Should fail or prevent loop: "cannot move directory into itself"* 192 | 193 | --- 194 | 195 | ### 17. **Move into existing directory with same file name** 196 | 197 | ```bash 198 | mkdir dir1 199 | touch dir1/file.txt 200 | touch file.txt 201 | mv file.txt dir1/ 202 | ``` 203 | 204 | ✅ *Should overwrite `dir1/file.txt` or keep both based on behavior (your shell likely overwrites)* 205 | 206 | --- 207 | 208 | ## 🧪 INVALID INPUTS & STRUCTURE 209 | 210 | ### 18. **Try to move nothing** 211 | 212 | ```bash 213 | mv 214 | ``` 215 | 216 | ❌ *Should return: "missing operand"* 217 | 218 | --- 219 | 220 | ### 19. **Try to move only one argument** 221 | 222 | ```bash 223 | mv only_source.txt 224 | ``` 225 | 226 | ❌ *Should return: "missing destination operand"* 227 | 228 | --- 229 | 230 | ### 20. **Trailing slashes in filenames (should still work)** 231 | 232 | ```bash 233 | touch weirdfile 234 | mv weirdfile weirdfile/ 235 | ``` 236 | 237 | ❌ *Should fail: `weirdfile/` is not a directory* 238 | 239 | --- 240 | 241 | ### 21. **Move file to a file path with a slash in middle (invalid path)** 242 | 243 | ```bash 244 | touch a.txt 245 | mv a.txt not/real/path.txt 246 | ``` 247 | 248 | ❌ *Should fail: intermediate directory does not exist* 249 | 250 | --- 251 | 252 | ## ⚠️ SYSTEM-LIKE BEHAVIOR 253 | 254 | ### 22. **Move file with same name but different case (case-sensitive)** 255 | 256 | ```bash 257 | touch lower.txt 258 | mv lower.txt LOWER.txt 259 | ls LOWER.txt 260 | ``` 261 | 262 | ✅ *Should rename depending on case sensitivity of filesystem* 263 | 264 | --- 265 | 266 | ### 23. **Move a directory onto itself** 267 | 268 | ```bash 269 | mkdir testdir 270 | mv testdir testdir 271 | ``` 272 | 273 | ❌ *Should do nothing or error: "invalid move"* 274 | 275 | --- 276 | 277 | ### 24. **Overwrite file with directory name** 278 | 279 | ```bash 280 | touch mydir 281 | mkdir actualdir 282 | mv actualdir mydir 283 | ``` 284 | 285 | ❌ *Should fail: cannot overwrite file with directory* 286 | 287 | --- 288 | 289 | ### 25. **Move files using relative paths** 290 | 291 | ```bash 292 | mkdir parent 293 | touch parent/file1 294 | mv parent/file1 file1_moved 295 | ls file1_moved 296 | ``` 297 | 298 | ✅ *Should move properly from relative path* 299 | --------------------------------------------------------------------------------