Skip to content

Commit 3e6d9fe

Browse files
committed
update the necessary documentation files and remove unused use statement from test
1 parent 918e7fa commit 3e6d9fe

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## [0.0.4] - 2019-09-24
2+
### Added
3+
- Add the possibility to delete a created short link
4+
### Changed
5+
- Introduce the new token
6+
- Edit the UriManager and Tests
7+
- Edit the UriController and Tests
8+
- Edit the README.md
9+
- Finally use the CHANGELOG.md file
10+
11+
## [0.0.3] - 2019-09-02
12+
### Added
13+
- Add a favicon
14+
- Add the apache package for symfony
15+
### Changed
16+
- Update the readme file to announce the mod_apache package
17+
18+
## [0.0.2] - 2019-08-31
19+
### Changed
20+
- Applied merge requests to simplify the UriController,
21+
the UriManager and fix some phpdocs
22+
23+
## [0.0.1] - 2019-06-23 (first release)
24+
### Added
25+
- Add the possibility to create short links
26+
- Add the possibility to use short links

README.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ To get Shorty up'n running follow these simple steps:
3333
- clone the repository
3434
- run composer install`
3535
- change the `PUT_TOKEN` inside the .env file to something you prefer
36+
- change the `DELETE_TOKEN` inside the .env file to something you prefer
3637
- run `php bin/console doctrine:database:create` to create the database
3738
- run `php bin/console doctrine:migrations:migrate --no-interaction ` to setup the schema
3839
- navigate to /public and run the local PHP Server with `php -S 127.0.0.1:8000`
@@ -59,13 +60,13 @@ you that Shorty is going out to have a cup of tea if there is some free time.
5960
### Create a short link
6061
If you want that Shorty creates a short link for you, you have to send
6162
him a PUT request. The following example will show you how it works with
62-
curl from a mac.
63+
curl in the terminal.
6364

6465
```
6566
curl -X PUT -H 'Authorization: 5449f071773861dca4d3b459aa79fcf5' -d 'https://github.com/patrick-blom/shorty' http://127.0.0.1:8000
6667
```
6768
```
68-
-X PUT: tell curl to send a PUT request
69+
-X PUT: Tell curl to send a PUT request
6970
-H 'Authorization: 5449f071773861dca4d3b459aa79fcf5': The token you provide under .env PUT_TOKEN (5449f071773861dca4d3b459aa79fcf5)
7071
-d 'https://github.com/patrick-blom/shorty': The Url you want to short (must be a syntactical valid url)
7172
http://127.0.0.1:8000: Your running Shorty
@@ -86,6 +87,37 @@ Shorty will now take the identifier and search for it in his database.
8687
If he finds a result he will pass a 301 HTTP Response including the
8788
original url back to the browser.
8889

90+
### Delete a short link
91+
Sometimes it happens that you pass something to Shorty you want to delete
92+
later. This can happen for several reasons. One reason could be that there is a typo
93+
in your very long url and you don't want to mess up the database. Another one
94+
could be, that you only want to share the short link for a limited amount of time.
95+
Never mind, there can always be a reason for the deletion of a short link. So if
96+
you want to delete a short link you have to send Shorty a DELETE request with the
97+
created short code. If we take the example from above, it would look like this.
98+
99+
```
100+
curl -X DELETE -H 'Authorization: 5449f071773861dca4d3b459aa79fcf5' -d '950a0065' http://127.0.0.1:8000
101+
```
102+
```
103+
-X DELETE: Tell curl to send a DELETE request
104+
-H 'Authorization: 5449f071773861dca4d3b459aa79fcf5': The token you provide under .env DELETE_TOKEN (5449f071773861dca4d3b459aa79fcf5)
105+
-d '950a0065': The short code which was created by Shorty during the PUT request
106+
http://127.0.0.1:8000: Your running Shorty
107+
```
108+
109+
If everything works as expected, Shorty will return a 410 HTTP Gone Response.
110+
Otherwise you will end up with an 400 HTTP Bad Request Response.
111+
112+
### Security
113+
Shorty's defense is really simple. The only thing between the world and the database
114+
are your authorization tokens. So please keep the following recommendations in mind
115+
116+
- choose long and complex tokens
117+
- never share your tokens
118+
- never use the same token for PUT and DELETE
119+
- always use HTTPS, if you can
120+
89121
## Testing
90122
If you want to test Shorty you can this by simply run a regular
91123
`composer install` and `composer test` in the project root. This will

tests/Unit/Factory/DeleteUriRequestFactoryTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use App\Exception\RequestDoesNotContainAValidShortyHashException;
66
use App\Factory\DeleteUriRequestFactory;
7-
use App\Factory\PutUriRequestFactory;
87
use App\Struct\DeleteUriRequest;
98
use PHPUnit\Framework\TestCase;
109
use Symfony\Component\HttpFoundation\Request;

0 commit comments

Comments
 (0)