Skip to content

Fix some typos (with crate-ci/typos + manual assistance) #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.6.2
current_version = 1.6.3
commit = False
tag = False

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Example usage

```curl -L -H "Content-Type: application/json" -d '{ "request": {"hosts":["harjoitus1.pvarki.fi"], "names":[{"C":"FI", "ST":"Jyvaskyla", "L":"KeskiSuomi", "O":"harjoitus1.pvarki.fi"}], "CN": "harjoitus1.pvarki.fi"}, "bundle":true, "profile":"client"}' 127.0.0.1:8000/takreg | jq```

The cfssl used behind API listents this kind of stuff https://github.com/cloudflare/cfssl/blob/master/doc/api/endpoint_newcert.txt
The cfssl used behind API listens this kind of stuff https://github.com/cloudflare/cfssl/blob/master/doc/api/endpoint_newcert.txt

# Enrollment - Enroll a new work_id

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rasenmaeher_api"
version = "1.6.2"
version = "1.6.3"
description = "python-rasenmaeher-api"
authors = [
"Aciid <703382+Aciid@users.noreply.github.com>",
Expand Down
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
""" python-rasenmaeher-api """
__version__ = "1.6.2" # NOTE Use `bump2version --config-file patch` to bump versions correctly
__version__ = "1.6.3" # NOTE Use `bump2version --config-file patch` to bump versions correctly
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/db/people.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ..web.api.middleware.datatypes import MTLSorJWTPayload
from .errors import NotFound, Deleted, BackendError, CallsignReserved
from ..cfssl.private import sign_csr, revoke_pem, validate_reason, ReasonTypes, refresh_ocsp
from ..prodcutapihelpers import post_to_all_products
from ..productapihelpers import post_to_all_products
from ..rmsettings import RMSettings
from ..kchelpers import KCClient, KCUserData
from .engine import EngineWrapper
Expand Down
4 changes: 2 additions & 2 deletions src/rasenmaeher_api/kchelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ async def _check_admin_role(self) -> None:
if self._kc_admin_role:
return
ret = await self.kcadmin.a_get_realm_roles(search_text="admin")
# If multipe roles match the search choose exact match
# If multiple roles match the search choose exact match
flt = [rolerep for rolerep in ret if rolerep["name"] == "admin"]
if not flt:
raise ValueError("KC has no configured 'admin' role")
self._kc_admin_role = flt[0]

async def check_user_roles(self, user: KCUserData) -> bool:
"""Chekc users roles in KC and update as needed, returns true if changes were made"""
"""Check users roles in KC and update as needed, returns true if changes were made"""
await self._check_admin_role()
kc_roles = {role["name"]: role for role in await self.kcadmin.a_get_realm_roles_of_user(user.kc_id)}
LOGGER.debug("Found KC roles: {} (user: {})".format(list(kc_roles.keys()), user.roles))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,52 @@ def check_kraftwerk_manifest() -> bool:


async def post_to_all_products(
url_suffix: str, data: Mapping[str, Any], respose_schema: Type[pydantic.BaseModel], collect_responses: bool = True
url_suffix: str, data: Mapping[str, Any], response_schema: Type[pydantic.BaseModel], collect_responses: bool = True
) -> Optional[Dict[str, Optional[pydantic.BaseModel]]]:
"""Call given POST endpoint on all products in the manifest"""
return await _method_to_all_products("post", url_suffix, data, respose_schema, collect_responses)
return await _method_to_all_products("post", url_suffix, data, response_schema, collect_responses)


async def put_to_all_products(
url_suffix: str, data: Mapping[str, Any], respose_schema: Type[pydantic.BaseModel], collect_responses: bool = True
url_suffix: str, data: Mapping[str, Any], response_schema: Type[pydantic.BaseModel], collect_responses: bool = True
) -> Optional[Dict[str, Optional[pydantic.BaseModel]]]:
"""Call given PUT endpoint on all products in the manifest"""
return await _method_to_all_products("put", url_suffix, data, respose_schema, collect_responses)
return await _method_to_all_products("put", url_suffix, data, response_schema, collect_responses)


async def get_from_all_products(
url_suffix: str, respose_schema: Type[pydantic.BaseModel], collect_responses: bool = True
url_suffix: str, response_schema: Type[pydantic.BaseModel], collect_responses: bool = True
) -> Optional[Dict[str, Optional[pydantic.BaseModel]]]:
"""Call given GET endpoint on all products in the manifest"""
return await _method_to_all_products("get", url_suffix, None, respose_schema, collect_responses)
return await _method_to_all_products("get", url_suffix, None, response_schema, collect_responses)


async def get_from_product(
name: str, url_suffix: str, respose_schema: Type[pydantic.BaseModel]
name: str, url_suffix: str, response_schema: Type[pydantic.BaseModel]
) -> Optional[pydantic.BaseModel]:
"""Call given GET endpoint on named product in the manifest"""
return await _method_to_product(name, "get", url_suffix, None, respose_schema)
return await _method_to_product(name, "get", url_suffix, None, response_schema)


async def post_to_product(
name: str, url_suffix: str, data: Mapping[str, Any], respose_schema: Type[pydantic.BaseModel]
name: str, url_suffix: str, data: Mapping[str, Any], response_schema: Type[pydantic.BaseModel]
) -> Optional[pydantic.BaseModel]:
"""Call given POST endpoint on named product in the manifest"""
return await _method_to_product(name, "post", url_suffix, data, respose_schema)
return await _method_to_product(name, "post", url_suffix, data, response_schema)


async def put_to_product(
name: str, url_suffix: str, data: Mapping[str, Any], respose_schema: Type[pydantic.BaseModel]
name: str, url_suffix: str, data: Mapping[str, Any], response_schema: Type[pydantic.BaseModel]
) -> Optional[pydantic.BaseModel]:
"""Call given PUT endpoint on named product in the manifest"""
return await _method_to_product(name, "put", url_suffix, data, respose_schema)
return await _method_to_product(name, "put", url_suffix, data, response_schema)


async def _method_to_all_products(
methodname: str,
url_suffix: str,
data: Optional[Mapping[str, Any]],
respose_schema: Type[pydantic.BaseModel],
response_schema: Type[pydantic.BaseModel],
collect_responses: bool = True,
) -> Optional[Dict[str, Optional[pydantic.BaseModel]]]:
"""Call given POST endpoint on call products in the manifest"""
Expand All @@ -83,9 +83,9 @@ async def _method_to_all_products(

async def handle_one(name: str) -> Tuple[str, Optional[pydantic.BaseModel]]:
"""Do one call"""
nonlocal url_suffix, methodname, respose_schema, data
nonlocal url_suffix, methodname, response_schema, data
try:
return name, await _method_to_product(name, methodname, url_suffix, data, respose_schema)
return name, await _method_to_product(name, methodname, url_suffix, data, response_schema)
except Exception as exc: # pylint: disable=W0718
LOGGER.exception(exc)
return name, None
Expand All @@ -107,7 +107,7 @@ async def _method_to_product(
methodname: str,
url_suffix: str,
data: Optional[Mapping[str, Any]],
respose_schema: Type[pydantic.BaseModel],
response_schema: Type[pydantic.BaseModel],
) -> Optional[Optional[pydantic.BaseModel]]:
"""Do a call to named product"""

Expand All @@ -130,7 +130,7 @@ async def _method_to_product(
resp.raise_for_status()
payload = await resp.json()
LOGGER.debug("{}({}) payload={}".format(methodname, url, payload))
retval = respose_schema.parse_obj(payload)
retval = response_schema.parse_obj(payload)
# Log a common error case here for DRY
if isinstance(retval, OperationResultResponse):
if not retval.success:
Expand Down
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/rmsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Config: # pylint: disable=too-few-public-methods
test_api_client_cert_header_value: str = "CN=fake.localmaeher.dev.pvarki.fi,O=N/A"
api_healthcheck_proto: str = "http://"
api_healthcheck_url: str = "/api/v1/healthcheck"
api_healthcheck_headers: str = '{"propably":"not_needed"}'
api_healthcheck_headers: str = '{"probably":"not_needed"}'

# Sentry's configuration.
sentry_dsn: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/web/api/descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pydantic import BaseModel, Extra, Field
from pydantic_collections import BaseCollectionModel

from ...prodcutapihelpers import get_from_all_products, get_from_product
from ...productapihelpers import get_from_all_products, get_from_product


LOGGER = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions src/rasenmaeher_api/web/api/firstuser/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Config: # pylint: disable=too-few-public-methods
{
"name": "normal",
"summary": "Description text",
"description": "This containts **description** of values.",
"description": "This contains **description** of values.",
"value": {"temp_admin_code": "[str] - temporary init admin users string"},
},
{
Expand Down Expand Up @@ -60,7 +60,7 @@ class Config: # pylint: disable=too-few-public-methods
{
"name": "normal",
"summary": "Description text",
"description": "This containts **description** of values.",
"description": "This contains **description** of values.",
"value": {
"callsign": "[str] - id/name for new user that is elevated to admin",
},
Expand Down
4 changes: 2 additions & 2 deletions src/rasenmaeher_api/web/api/firstuser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def get_check_code(
LOGGER.error("{} : {}".format(request.url, _reason))
raise HTTPException(status_code=500, detail=_reason)

# Code alreay used err.
# Code already used err.
if res.used_on is not None:
_reason = "Code already used"
LOGGER.error("{} : {}".format(request.url, _reason))
Expand Down Expand Up @@ -84,7 +84,7 @@ async def post_admin_add(
anon_admin_user = await Person.by_callsign(callsign="anon_admin")
new_admin = await enrollment.approve(approver=anon_admin_user)

# FIXME Should tbe TaskMaster feature
# FIXME Should the TaskMaster feature
async def tms_wait() -> None:
"""Wait for background tasks to avoid race conditions"""
tma = TaskMaster.singleton()
Expand Down
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/web/api/healthcheck/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .schema import BasicHealthCheckResponse, AllProductsHealthCheckResponse
from ....db import Person
from ....rmsettings import switchme_to_singleton_call
from ....prodcutapihelpers import check_kraftwerk_manifest, get_from_all_products
from ....productapihelpers import check_kraftwerk_manifest, get_from_all_products

router = APIRouter()
LOGGER = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions src/rasenmaeher_api/web/api/instructions/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# pylint: disable=too-few-public-methods


class AllProdcutsInstructionFragments(BaseModel):
class AllProductsInstructionFragments(BaseModel):
"""DEPRECATED! Fragments for all products"""

fragments: Dict[str, Optional[UserInstructionFragment]] = Field(
Expand Down Expand Up @@ -56,7 +56,7 @@ class Config: # pylint: disable=too-few-public-methods
extra = Extra.forbid


class AllProdcutsInstructionFiles(BaseModel):
class AllProductsInstructionFiles(BaseModel):
"""DEPRECATED! user files for all products"""

files: Dict[str, Optional[ProductFileList]] = Field(
Expand Down
18 changes: 9 additions & 9 deletions src/rasenmaeher_api/web/api/instructions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@


from .schema import (
AllProdcutsInstructionFragments,
AllProductsInstructionFragments,
ProductFileList,
AllProdcutsInstructionFiles,
AllProductsInstructionFiles,
InstructionData,
)
from ..middleware.user import ValidUser
from ....prodcutapihelpers import get_from_all_products, post_to_all_products, post_to_product
from ....productapihelpers import get_from_all_products, post_to_all_products, post_to_product
from ....db import Person


Expand All @@ -23,27 +23,27 @@

@router.get(
"/admin",
response_model=AllProdcutsInstructionFragments,
response_model=AllProductsInstructionFragments,
dependencies=[Depends(ValidUser(auto_error=True))],
deprecated=True,
)
async def admin_instruction_fragment() -> AllProdcutsInstructionFragments:
async def admin_instruction_fragment() -> AllProductsInstructionFragments:
"""Return admin instructions"""
responses = await get_from_all_products("api/v1/admins/fragment", UserInstructionFragment)
if responses is None:
raise ValueError("Everything is broken")
return AllProdcutsInstructionFragments(
return AllProductsInstructionFragments(
fragments={key: cast(UserInstructionFragment, val) for key, val in responses.items()}
)


@router.get(
"/user",
response_model=AllProdcutsInstructionFiles,
response_model=AllProductsInstructionFiles,
dependencies=[Depends(ValidUser(auto_error=True))],
deprecated=True,
)
async def user_instruction_fragment(request: Request) -> AllProdcutsInstructionFiles:
async def user_instruction_fragment(request: Request) -> AllProductsInstructionFiles:
"""Return end-user files"""
person = cast(Person, request.state.person)
user = UserCRUDRequest(
Expand All @@ -53,7 +53,7 @@ async def user_instruction_fragment(request: Request) -> AllProdcutsInstructionF
responses = await post_to_all_products("api/v1/clients/fragment", user.dict(), ProductFileList)
if responses is None:
raise ValueError("Everything is broken")
return AllProdcutsInstructionFiles(files={key: cast(ProductFileList, val) for key, val in responses.items()})
return AllProductsInstructionFiles(files={key: cast(ProductFileList, val) for key, val in responses.items()})


@router.get(
Expand Down
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/web/api/product/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Product registeration API."""
"""Product registration API."""
from rasenmaeher_api.web.api.product.views import router

__all__ = ["router"]
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/web/api/product/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Product registeration API views."""
"""Product registration API views."""
import logging

from fastapi import APIRouter, Depends, HTTPException, Request
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from rasenmaeher_api.web.application import get_app
from rasenmaeher_api.rmsettings import switchme_to_singleton_call
from rasenmaeher_api.prodcutapihelpers import check_kraftwerk_manifest
from rasenmaeher_api.productapihelpers import check_kraftwerk_manifest
from rasenmaeher_api.testhelpers import create_test_users
from rasenmaeher_api.mtlsinit import check_settings_clientpaths, CERT_NAME_PREFIX
from rasenmaeher_api.db.dbinit import init_db
Expand All @@ -35,7 +35,7 @@
JWT_PATH = DATA_PATH / Path("jwt")


# FIXME Should tbe TaskMaster feature
# FIXME Should the TaskMaster feature
async def tms_wait() -> None:
"""Wait for background tasks to avoid race conditions"""
tma = TaskMaster.singleton()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def test_product_description(unauth_client: TestClient, lang: str) -> None

@pytest.mark.parametrize("lang", ["fi", "en"])
@pytest.mark.asyncio(loop_scope="session")
async def test_product_instructons(user_mtls_client: TestClient, lang: str) -> None:
async def test_product_instructions(user_mtls_client: TestClient, lang: str) -> None:
"""Make sure we get product instructions"""
resp = await user_mtls_client.get(f"/api/v1/instructions/fake/{lang}")
assert resp
Expand Down
2 changes: 1 addition & 1 deletion tests/test_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ async def test_create_as_usr(tilauspalvelu_jwt_user_client: TestClient) -> None:
# INVITE CODE DEACTIVATE
@pytest.mark.asyncio(loop_scope="session")
@pytest.mark.parametrize("tilauspalvelu_jwt_admin_client", [{"test": "value", "xclientcert": False}], indirect=True)
async def test_invitecode_dectivate(tilauspalvelu_jwt_admin_client: TestClient) -> None:
async def test_invitecode_deactivate(tilauspalvelu_jwt_admin_client: TestClient) -> None:
"""
Test - deactivate invite code
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_rasenmaeher_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def test_version() -> None:
"""Make sure version matches expected"""
assert __version__ == "1.6.2"
assert __version__ == "1.6.3"


@pytest.mark.asyncio(loop_scope="session")
Expand Down