-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* api.pyをPATに対応して既存のテストが通るところまで * 環境変数・引数にPATを指定してインスタンスを生成できるようにした * AnnofabApiをいくつか修正 * Unauthorize時のlogin&retry処理を、IdPassが渡されていた時のみにした * Patを渡された場合のlogin時、self.tokensにPatを転写するようにした * logoutの処理と対象になるように * create_test_project.pyがendpointを引数に取れるようにした * Patをcredentialsに利用する場合のtokensへの転写をコンストラクタではなくリクエストを実行する直前に行うようにした * README.mdを更新 * 正しくないコメントを修正 * input_mfa_code_via_stdin のコメントを修正 * rename test_build.py to test_local_build.py CIでのテスト対象とするため
- Loading branch information
Showing
8 changed files
with
221 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from dataclasses import dataclass | ||
from typing import Dict, Protocol | ||
|
||
|
||
class HasAuthToken(Protocol): | ||
@property | ||
def auth_token(self) -> str: ... | ||
|
||
|
||
@dataclass(frozen=True) | ||
class IdPass: | ||
user_id: str | ||
password: str | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Pat(HasAuthToken): | ||
"""Personal Access Token""" | ||
|
||
token: str | ||
|
||
@property | ||
def auth_token(self) -> str: | ||
return f"Bearer {self.token}" | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Tokens(HasAuthToken): | ||
"""IdPassを元にログインしたあとに取得されるトークン情報""" | ||
|
||
id_token: str | ||
access_token: str | ||
refresh_token: str | ||
|
||
@property | ||
def auth_token(self) -> str: | ||
return self.id_token | ||
|
||
def to_dict(self) -> Dict[str, str]: | ||
return { | ||
"id_token": self.id_token, | ||
"access_token": self.access_token, | ||
"refresh_token": self.refresh_token, | ||
} | ||
|
||
@staticmethod | ||
def from_dict(d: Dict[str, str]) -> "Tokens": | ||
return Tokens(id_token=d["id_token"], access_token=d["access_token"], refresh_token=d["refresh_token"]) |
Oops, something went wrong.