feat(s3): S3アドオンにSigV4署名を追加#746
Conversation
Co-Authored-By: An Qiuyu <qiuyu.an@hotmail.com>
- import InstitutionFactory - test_s3_settings_input_empty_secret_key: assert_equals/assert_in -> pytest assert + rv.text - test_s3_settings_rdm_addons_denied: post_json -> post(url, json=...) + pytest assert + rv.text
…7/G8 tests
- Replace all self.app.post(url, json={...}) with post_json(url, {...})
and self.app.put(url, json={...}) with put_json(url, {...}) so tests
work with the webtest_plus version in CI (older version lacks json= kwarg)
- Add expect_errors=True for all calls that expect 4xx responses
- Add expect_errors=True to delete/get calls that expect 401/403
- Add G1 (missing key field → 400), G2 (get_user_info=None → 400),
G4 (bad bucket name → 400), G5 (provider_id format + dedup),
G7 (bucket_exists empty), G8 (can_list None) coverage
mock.patch(...).return_value sets attribute on the patcher object, not the started Mock. Use mock.patch(..., return_value=mock.Mock(id=..., ...)) so user_info.id / user_info.display_name are accessible in the view. Fixes test_provider_id_format and test_provider_id_dedup.
Wrappers were accidentally dropped when the feature branch was created.
Restored ${ _("...") } for all 20 translatable strings across:
- s3_credentials_modal.mako (5 strings)
- s3_node_settings.mako (10 strings)
- s3_user_settings.mako (5 strings)
Feature-branch additions preserved: aria-label/alt on img tags,
OAuth comment fix, text-muted class removal from th.
…lity boto (v2) was removed as part of SigV4 migration. boto3/botocore are in the root requirements.txt. The Jenkins Dockerfile still has COPY ./addons/s3/requirements.txt, so an empty file is needed to prevent Docker build failure.
| # otherwise use the default as it handles bucket outside of the US | ||
| connection.calling_format = OrdinaryCallingFormat() | ||
| # bucket names are dns-compliant, therefore must be lowercase | ||
| bucket_name = bucket_name.lower() |
There was a problem hiding this comment.
既存bucket参照時に bucket_name.lower() で暗黙変換するのは避けるべきです。現行S3ルールでは新規bucket名は小文字前提ですが、AWS公式上、古いus-east-1 bucketには大文字/underscoreを含む名前が存在し得ます。互換維持するなら入力/保存済みbucket名をそのまま使い、互換を切るなら小文字化ではなく明示的にunsupportedとしてエラーにしてください。暗黙に MyBucket を mybucket として問い合わせるのは危険です。
There was a problem hiding this comment.
既存 bucket 参照時に暗黙で小文字化すると、ご指摘の通りAWS公式上、古いリージョンの場合、別 bucket を参照する可能性があるため、bucket_exists() / get_bucket_location_or_error() では入力された bucket 名をそのまま使うよう修正します。新規 bucket 名の制約は validate_bucket_name() 側で扱うようにしました。
| if not self.folder_id: | ||
| raise exceptions.AddonError('Cannot serialize settings for S3 addon') | ||
|
|
||
| bucket_name = self.folder_id.split(':')[0] |
There was a problem hiding this comment.
既存データでは folder_id が旧形式のbucket名のみで保存されている可能性があるため、folder_id='bucket' と新形式 folder_id='bucket:/' / bucket:/prefix/ の両方でWaterButler settingsが期待通りになることをテストで保証してほしいです。
There was a problem hiding this comment.
既存データの folder_id='bucket' と、新形式の folder_id='bucket:/' / 'bucket:/prefix/' の双方で WaterButler settings が期待通りになることを test_model.py に追加しました。
概要
既存のS3アドオンをレガシーSignature V2からSignature V4認証に移行し、SigV4が必要なAWSリージョン(例:
ap-northeast-1)との互換性を実現します。変更内容
モデル (
addons/s3/models.py)s3_auth_typeフィールドを追加ビュー (
addons/s3/views.py)ユーティリティ (
addons/s3/utils.py)get_bucket_names()をSigV4署名リクエストに対応フロントエンド (
addons/s3/static/)s3NodeConfig.js、s3UserConfig.jsをSigV4認証フローに対応テスト (
addons/s3/tests/)test_model.py、test_view.py、test_serializer.pyを新認証フローに適合その他
README.mdを追加requirements.txtに必要な依存関係を追加addons/s3/requirements.txtを削除関連PR
Based on anqiuy/RDM-osf.io@feature/s3-sigv4