Skip to content

Commit

Permalink
Fix ci, rfs #273
Browse files Browse the repository at this point in the history
  • Loading branch information
rednafi committed Oct 21, 2023
1 parent 3d6d35b commit 1410ff6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 52 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ name: Test Container

on:
push:
branches:
- master
tags:
- "v*"


pull_request:
branches:
- master
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ name: Run tests

on:
push:
branches:
- master
tags:
- "v*"


pull_request:
branches:
- master
Expand Down
84 changes: 42 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ If you want to run the app locally, without using Docker, then:
- Create a virtual environment. Here I'm using Python's built-in venv in a Unix system.
Run:

```sh
python3.12 -m venv .venv
```
```sh
python3.12 -m venv .venv
```

- Activate the environment. Run:

Expand Down Expand Up @@ -99,16 +99,16 @@ If you want to run the app locally, without using Docker, then:
use OAuth2 (with hashed password and Bearer with JWT) based authentication. In this
case, the username and password is `ubuntu` and `debian` respectively.

![Screenshot from 2020-06-21 22-18-25][screenshot_2]
![Screenshot from 2020-06-21 22-18-25][screenshot_2]

Clicking the `authorize` button will bring up a screen like this:
Clicking the `authorize` button will bring up a screen like this:

![Screenshot from 2020-06-21 22-18-59][screenshot_3]
![Screenshot from 2020-06-21 22-18-59][screenshot_3]

- Then select any of the `api_a` or `api_b` APIs and put an integer in the number box and
click the `authorize` button.

![Screenshot from 2020-06-21 22-31-19][screenshot_4]
![Screenshot from 2020-06-21 22-31-19][screenshot_4]

- Hitting the API should give a json response with random integers.

Expand All @@ -118,47 +118,47 @@ If you want to run the app locally, without using Docker, then:
highlighted curl command in your terminal. Make sure you've got `jq` installed in your
system.
```bash
curl -X GET "http://localhost:5002/api_a/22" \
-H "accept: application/json" \
-H "Authorization: Bearer $(curl -X POST "http://localhost:5002/token" \
-H "accept: application/x-www-form-urlencoded" \
-d "username=ubuntu&password=debian" | jq -r ".access_token")"
```
```sh
curl -X GET "http://localhost:5002/api_a/22" \
-H "accept: application/json" \
-H "Authorization: Bearer $(curl -X POST "http://localhost:5002/token" \
-H "accept: application/x-www-form-urlencoded" \
-d "username=ubuntu&password=debian" | jq -r ".access_token")"
```
This should show a response like this:
This should show a response like this:
```json
{
"seed": 22,
"random_first": 5,
"random_second": 13
}
```
```json
{
"seed": 22,
"random_first": 5,
"random_second": 13
}
```
- To test the `GET` APIs with Python, you can use a http client library like
[httpx][httpx]:
```python
import httpx
with httpx.Client() as client:
# Collect the API token.
r = client.post(
"http://localhost:5002/token",
headers={"Content-Type": "application/x-www-form-urlencoded"},
data={"username": "ubuntu", "password": "debian"},
)
token = r.json()["access_token"]
# Use the token value to hit the API.
r = client.get(
"http://localhost:5002/api_a/22",
headers={"Accept": "application/json", "Authorization": f"Bearer {token}"},
)
print(r.json())
```
```python
import httpx
with httpx.Client() as client:
# Collect the API token.
r = client.post(
"http://localhost:5002/token",
headers={"Content-Type": "application/x-www-form-urlencoded"},
data={"username": "ubuntu", "password": "debian"},
)
token = r.json()["access_token"]
# Use the token value to hit the API.
r = client.get(
"http://localhost:5002/api_a/22",
headers={"Accept": "application/json", "Authorization": f"Bearer {token}"},
)
print(r.json())
```
## Folder structure
Expand Down

0 comments on commit 1410ff6

Please sign in to comment.