Skip to content

Commit

Permalink
Update filter_headers and filter_query_parameters in integration tests.
Browse files Browse the repository at this point in the history
- Moves TypeAlias import from typing to typing_extensions for Python 3.9 compatibility.
- Update workflows to include environment setting for testing
- Added an 'environment: testing' setting in the pre-commit and pytest jobs within the workflows. Branches are now specified as arrays.
- Update environment variables in workflows for USER_NAME, FRIEND_USER_NAME, and BLOCKED_USER_NAME.
- Updated Python setup to version 5 in workflow files. Switched from using 'pip install poetry' to 'pipx install poetry'.
  • Loading branch information
isFakeAccount committed Jun 16, 2024
1 parent c586e33 commit 2f35e14
Show file tree
Hide file tree
Showing 73 changed files with 541 additions and 2,252 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/code_coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
name: code coverage
on:
push:
branches: "master"
branches: ["master"]
pull_request:
branches: "master"
branches: ["master"]

jobs:
pre-commit:
runs-on: ubuntu-latest
environment: testing
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
run: pipx install poetry

- name: Install dependencies and build package
run: |
Expand All @@ -30,7 +29,9 @@ jobs:
poetry run pytest --cov-config=.coveragerc --junitxml=pytest.xml --cov=psnawp_api | tee pytest-coverage.txt
env:
NPSSO_CODE: ${{ secrets.NPSSO_CODE }}
USER_NAME: ${{ secrets.USER_NAME }}
USER_NAME: ${{ vars.USER_NAME }}
FRIEND_USER_NAME: ${{ vars.FRIEND_USER_NAME }}
BLOCKED_USER_NAME: ${{ vars.BLOCKED_USER_NAME }}

- name: PyTest Coverage comment
id: coverageComment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
run: pip install poetry
run: pipx install poetry

- name: Get Tag Name
id: get_and_remove_v_from_tag
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ on:
push:
branches:
- "*"
pull_request:
branches:
- "*"

jobs:
pytest:
runs-on: ${{ matrix.os }}-latest
environment: testing
strategy:
matrix:
os: [ubuntu, windows, macos]
Expand All @@ -19,22 +17,25 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }} ${{ matrix.os }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
run: pipx install poetry

- name: Install dependencies and build package
run: |
poetry install
- name: Test with pytest
run: |
echo "USERNAME: $USER_NAME"
echo "FRIEND_USER_NAME: $FRIEND_USER_NAME"
echo "BLOCKED_USER_NAME: $BLOCKED_USER_NAME"
poetry run pytest
env:
NPSSO_CODE: ${{ secrets.NPSSO_CODE }}
USER_NAME: ${{ secrets.USER_NAME }}
USER_NAME: ${{ vars.USER_NAME }}
FRIEND_USER_NAME: ${{ vars.FRIEND_USER_NAME }}
BLOCKED_USER_NAME: ${{ vars.BLOCKED_USER_NAME }}
4 changes: 2 additions & 2 deletions src/psnawp_api/core/request_builder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any, TypeAlias, TypedDict, cast
from typing import TYPE_CHECKING, Any, TypedDict, cast

from requests import Response, request
from typing_extensions import NotRequired, Unpack
from typing_extensions import NotRequired, TypeAlias, Unpack

from psnawp_api.core.psnawp_exceptions import (
PSNAWPBadRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def filter_response_information(response: Response) -> Response:
cassette_library_dir="tests/integration_tests/integration_test_psnawp_api/cassettes",
record_mode=RecordMode.ONCE,
match_on=["uri", "method"],
filter_headers=["Authorization", "Cookie", "Set-Cookie"],
filter_headers=["Authorization", "Cookie", "Set-Cookie", "Location"],
filter_query_parameters=["cid"],
filter_post_data_parameters=["refresh_token", "code"],
before_record_response=filter_response_information,
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interactions:
X-Requested-With:
- com.scee.psxandroid
method: GET
uri: https://ca.account.sony.com/api/authz/v3/oauth/authorize?access_type=offline&cid=00000000-0000-0000-0000-b025aa3b2674&client_id=09515159-7237-4370-9b40-3806e67c0891&device_base_font_size=10&device_profile=mobile&elements_visibility=no_aclink&enable_scheme_error_code=true&no_captcha=true&PlatformPrivacyWs1=minimal&redirect_uri=com.scee.psxandroid.scecompcall%3A%2F%2Fredirect&response_type=code&scope=psn%3Amobile.v2.core+psn%3Aclientapp&service_entity=urn%3Aservice-entity%3Apsn&service_logo=ps&smcid=psapp%3Asignin&support_scheme=sneiprls&turnOnTrustedBrowser=true&ui=pr
uri: https://ca.account.sony.com/api/authz/v3/oauth/authorize?PlatformPrivacyWs1=minimal&access_type=offline&client_id=09515159-7237-4370-9b40-3806e67c0891&device_base_font_size=10&device_profile=mobile&elements_visibility=no_aclink&enable_scheme_error_code=true&no_captcha=true&redirect_uri=com.scee.psxandroid.scecompcall%3A%2F%2Fredirect&response_type=code&scope=psn%3Amobile.v2.core+psn%3Aclientapp&service_entity=urn%3Aservice-entity%3Apsn&service_logo=ps&smcid=psapp%3Asignin&support_scheme=sneiprls&turnOnTrustedBrowser=true&ui=pr
response:
body:
string: ''
Expand All @@ -40,11 +40,11 @@ interactions:
Content-Length:
- '0'
Date:
- Mon, 10 Jun 2024 00:27:52 GMT
- Sun, 16 Jun 2024 22:29:30 GMT
Expires:
- '0'
Location:
- com.scee.psxandroid.scecompcall://redirect/?code=v3.55wKaX&cid=00000000-0000-0000-0000-b025aa3b2674
- com.scee.psxandroid.scecompcall://redirect/?code=v3.AA9221&cid=00000000-0000-0000-0000-b025aa3b2674
Server:
- nginx
Set-Cookie: REDACTED
Expand All @@ -59,9 +59,9 @@ interactions:
X-Psn-Correlation-Id:
- 00000000-0000-0000-0000-b025aa3b2674
X-Psn-Request-Id:
- a4b84245d6993251bcc853cfb6c7d9dc
- a62a387dccd9c0a735595a71c308cd76
X-RequestId:
- a4b84245d6993251bcc853cfb6c7d9dc
- a62a387dccd9c0a735595a71c308cd76
X-XSS-Protection:
- 1; mode=block
status:
Expand Down Expand Up @@ -105,7 +105,7 @@ interactions:
Content-Type:
- application/json;charset=UTF-8
Date:
- Mon, 10 Jun 2024 00:27:52 GMT
- Sun, 16 Jun 2024 22:29:31 GMT
Server:
- nginx
Set-Cookie: REDACTED
Expand All @@ -116,9 +116,9 @@ interactions:
X-Psn-Correlation-Id:
- 00000000-0000-0000-0000-b025aa3b2674
X-Psn-Request-Id:
- 01b077bdb00e21dcc6516c92116bf262
- c88fd443a3118e48b1c234941511e0b0
X-RequestId:
- 01b077bdb00e21dcc6516c92116bf262
- c88fd443a3118e48b1c234941511e0b0
status:
code: 200
message: OK
Expand Down Expand Up @@ -151,18 +151,18 @@ interactions:
Content-Type:
- application/json
Date:
- Mon, 10 Jun 2024 00:27:52 GMT
- Sun, 16 Jun 2024 22:29:31 GMT
Server:
- nginx
Set-Cookie: REDACTED
X-CorrelationId:
- 36b6f374-8044-492c-befd-1d8ff2ad47f5
- cbee4a15-8b15-4079-b23f-620d17242f7f
X-Psn-Correlation-Id:
- 36b6f374-8044-492c-befd-1d8ff2ad47f5
- cbee4a15-8b15-4079-b23f-620d17242f7f
X-Psn-Request-Id:
- 36b6f374-8044-492c-befd-1d8ff2ad47f5
- cbee4a15-8b15-4079-b23f-620d17242f7f
X-RequestId:
- 36b6f374-8044-492c-befd-1d8ff2ad47f5
- cbee4a15-8b15-4079-b23f-620d17242f7f
status:
code: 200
message: OK
Expand Down Expand Up @@ -216,7 +216,7 @@ interactions:
Content-Type:
- application/json
Date:
- Mon, 10 Jun 2024 00:27:53 GMT
- Sun, 16 Jun 2024 22:29:31 GMT
Server:
- Apache
Set-Cookie: REDACTED
Expand All @@ -225,7 +225,7 @@ interactions:
X-Content-Type-Options:
- nosniff
X-Psn-Track-Id:
- 0321682397294235811
- 0513448652100387479
status:
code: 200
message: OK
Expand Down Expand Up @@ -265,20 +265,20 @@ interactions:
Content-Type:
- application/json;charset=UTF-8
Date:
- Mon, 10 Jun 2024 00:27:53 GMT
- Sun, 16 Jun 2024 22:29:31 GMT
Server:
- nginx
Set-Cookie: REDACTED
X-Content-Type-Options:
- nosniff
X-CorrelationId:
- 881a0f6f-ad85-4c8e-94f1-f69a600e3237
- f1b32c3c-1f5f-4fcf-9c06-fe4928c62ca3
X-Psn-Correlation-Id:
- 881a0f6f-ad85-4c8e-94f1-f69a600e3237
- f1b32c3c-1f5f-4fcf-9c06-fe4928c62ca3
X-Psn-Request-Id:
- 08422680e9b46934141a243d08adf4d6
- 6b5582c04f411b16a9d1104b78456571
X-RequestId:
- 08422680e9b46934141a243d08adf4d6
- 6b5582c04f411b16a9d1104b78456571
status:
code: 200
message: OK
Expand Down Expand Up @@ -311,18 +311,18 @@ interactions:
Content-Type:
- application/json
Date:
- Mon, 10 Jun 2024 00:27:53 GMT
- Sun, 16 Jun 2024 22:29:31 GMT
Server:
- nginx
Set-Cookie: REDACTED
X-CorrelationId:
- ead43b54-bfdc-49e0-b586-c9827af5ebe4
- df492998-fadf-4c82-96c5-bb246fe6182b
X-Psn-Correlation-Id:
- ead43b54-bfdc-49e0-b586-c9827af5ebe4
- df492998-fadf-4c82-96c5-bb246fe6182b
X-Psn-Request-Id:
- ead43b54-bfdc-49e0-b586-c9827af5ebe4
- df492998-fadf-4c82-96c5-bb246fe6182b
X-RequestId:
- ead43b54-bfdc-49e0-b586-c9827af5ebe4
- df492998-fadf-4c82-96c5-bb246fe6182b
status:
code: 200
message: OK
Expand Down Expand Up @@ -376,7 +376,7 @@ interactions:
Content-Type:
- application/json
Date:
- Mon, 10 Jun 2024 00:27:53 GMT
- Sun, 16 Jun 2024 22:29:32 GMT
Server:
- Apache
Set-Cookie: REDACTED
Expand All @@ -385,7 +385,7 @@ interactions:
X-Content-Type-Options:
- nosniff
X-Psn-Track-Id:
- 0561955786020588490
- 0257938140355215022
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interactions:
X-Requested-With:
- com.scee.psxandroid
method: GET
uri: https://ca.account.sony.com/api/authz/v3/oauth/authorize?access_type=offline&cid=00000000-0000-0000-0000-b025aa3b2674&client_id=09515159-7237-4370-9b40-3806e67c0891&device_base_font_size=10&device_profile=mobile&elements_visibility=no_aclink&enable_scheme_error_code=true&no_captcha=true&PlatformPrivacyWs1=minimal&redirect_uri=com.scee.psxandroid.scecompcall%3A%2F%2Fredirect&response_type=code&scope=psn%3Amobile.v2.core+psn%3Aclientapp&service_entity=urn%3Aservice-entity%3Apsn&service_logo=ps&smcid=psapp%3Asignin&support_scheme=sneiprls&turnOnTrustedBrowser=true&ui=pr
uri: https://ca.account.sony.com/api/authz/v3/oauth/authorize?PlatformPrivacyWs1=minimal&access_type=offline&client_id=09515159-7237-4370-9b40-3806e67c0891&device_base_font_size=10&device_profile=mobile&elements_visibility=no_aclink&enable_scheme_error_code=true&no_captcha=true&redirect_uri=com.scee.psxandroid.scecompcall%3A%2F%2Fredirect&response_type=code&scope=psn%3Amobile.v2.core+psn%3Aclientapp&service_entity=urn%3Aservice-entity%3Apsn&service_logo=ps&smcid=psapp%3Asignin&support_scheme=sneiprls&turnOnTrustedBrowser=true&ui=pr
response:
body:
string: ''
Expand All @@ -40,11 +40,11 @@ interactions:
Content-Length:
- '0'
Date:
- Mon, 10 Jun 2024 00:27:51 GMT
- Sun, 16 Jun 2024 22:29:29 GMT
Expires:
- '0'
Location:
- com.scee.psxandroid.scecompcall://redirect/?code=v3.4GkvgH&cid=00000000-0000-0000-0000-b025aa3b2674
- com.scee.psxandroid.scecompcall://redirect/?code=v3.fZ7UR3&cid=00000000-0000-0000-0000-b025aa3b2674
Server:
- nginx
Set-Cookie: REDACTED
Expand All @@ -59,9 +59,9 @@ interactions:
X-Psn-Correlation-Id:
- 00000000-0000-0000-0000-b025aa3b2674
X-Psn-Request-Id:
- 2c061f3392c682f34d4095e87bef4478
- 498e79905e4a4305e635719cd89bf195
X-RequestId:
- 2c061f3392c682f34d4095e87bef4478
- 498e79905e4a4305e635719cd89bf195
X-XSS-Protection:
- 1; mode=block
status:
Expand Down Expand Up @@ -105,7 +105,7 @@ interactions:
Content-Type:
- application/json;charset=UTF-8
Date:
- Mon, 10 Jun 2024 00:27:51 GMT
- Sun, 16 Jun 2024 22:29:29 GMT
Server:
- nginx
Set-Cookie: REDACTED
Expand All @@ -116,9 +116,9 @@ interactions:
X-Psn-Correlation-Id:
- 00000000-0000-0000-0000-b025aa3b2674
X-Psn-Request-Id:
- 658fb65d49901f93a0f44ecadd3cfa25
- 268f9393e20620b30f45ecf190170720
X-RequestId:
- 658fb65d49901f93a0f44ecadd3cfa25
- 268f9393e20620b30f45ecf190170720
status:
code: 200
message: OK
Expand Down Expand Up @@ -151,18 +151,18 @@ interactions:
Content-Type:
- application/json
Date:
- Mon, 10 Jun 2024 00:27:51 GMT
- Sun, 16 Jun 2024 22:29:30 GMT
Server:
- nginx
Set-Cookie: REDACTED
X-CorrelationId:
- 1c0c16a0-69cb-4db2-be89-e827c7ec3cb9
- 07a75ea9-bab4-4a59-b1aa-a12bc175cb8e
X-Psn-Correlation-Id:
- 1c0c16a0-69cb-4db2-be89-e827c7ec3cb9
- 07a75ea9-bab4-4a59-b1aa-a12bc175cb8e
X-Psn-Request-Id:
- 1c0c16a0-69cb-4db2-be89-e827c7ec3cb9
- 07a75ea9-bab4-4a59-b1aa-a12bc175cb8e
X-RequestId:
- 1c0c16a0-69cb-4db2-be89-e827c7ec3cb9
- 07a75ea9-bab4-4a59-b1aa-a12bc175cb8e
status:
code: 200
message: OK
Expand Down Expand Up @@ -216,7 +216,7 @@ interactions:
Content-Type:
- application/json
Date:
- Mon, 10 Jun 2024 00:27:52 GMT
- Sun, 16 Jun 2024 22:29:30 GMT
Server:
- Apache
Set-Cookie: REDACTED
Expand All @@ -225,7 +225,7 @@ interactions:
X-Content-Type-Options:
- nosniff
X-Psn-Track-Id:
- '0725624462237645410'
- 0347049116146756001
status:
code: 200
message: OK
Expand Down
Loading

0 comments on commit 2f35e14

Please sign in to comment.