Skip to content

Commit

Permalink
Merge pull request #172 from ut-issl/feature/test_use_os_env
Browse files Browse the repository at this point in the history
認証情報を環境変数から取得できるようにした
  • Loading branch information
yngyu authored Jan 11, 2022
2 parents f2aa923 + f8a0543 commit 99b697d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Examples/minimum_user_for_s2e/src/src_user/Test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,14 @@ or
cd ./test/src_user/Applications/UserDefined/
pytest -m real -v test_tlm_mem_dump.py
```

## 認証情報について
wings と通信するにあたりに対して認証情報を渡す必要がある. `authorization.json.temp` と同じ key を持つ正しい `authorization.json` を誰かからもらうか,又はそれぞれの key に対応する環境変数を埋めること. 対応を下表に示す.

| `authorization.json` の key | 環境変数 |
| :-------------------------- | :------------------ |
| client_id | WINGS_CLIENT_ID |
| client_secret | WINGS_CLIENT_SECRET |
| grant_type | WINGS_GRANT_TYPE |
| username | WINGS_USERNAME |
| password | WINGS_PASSWORD |
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
import isslwings as wings

def get_wings_operation():
with open(os.path.dirname(__file__) + "/../authorization.json") as f:
authorization = json.load(f)
authorization = dict(
client_id = os.environ.get("WINGS_CLIENT_ID"),
client_secret = os.environ.get("WINGS_CLIENT_SECRET"),
grant_type = os.environ.get("WINGS_GRANT_TYPE"),
username = os.environ.get("WINGS_USERNAME"),
password = os.environ.get("WINGS_PASSWORD")
)

# 環境変数があればそちらを優先
if None in authorization.values():
with open(os.path.dirname(__file__) + "/../authorization.json") as f:
authorization = json.load(f)
return wings.Operation(authentication_info=authorization)

0 comments on commit 99b697d

Please sign in to comment.