Skip to content

Commit af820d5

Browse files
authored
Merge pull request #36 from lieunguyen-tma/feature/wiki-operation
ユーザー機能テストにおけるWiki操作機能のテスト追加
2 parents 113f604 + 5ed5d8a commit af820d5

38 files changed

Lines changed: 26837 additions & 8 deletions

File tree

.github/scripts/generate_ci_config.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -xeuo pipefail
33

44
if [[ $# -lt 2 ]]; then
55
cat >&2 <<'USAGE'
6-
Usage: generate_ci_config.sh <output_path> <base_config_yaml> [--minio] [--jupyterhub] [--weko] [--flowable] [--s3compatsigv4] [--s3compatsigv4-inst]
6+
Usage: generate_ci_config.sh <output_path> <base_config_yaml> [--minio] [--jupyterhub] [--weko] [--flowable] [--s3compatsigv4] [--s3compatsigv4-inst] [--wiki]
77
USAGE
88
exit 1
99
fi
@@ -17,6 +17,7 @@ WEKO=false
1717
FLOWABLE=false
1818
S3COMPATSIGV4=false
1919
S3COMPATSIGV4_INST=false
20+
WIKI=false
2021

2122
for arg in "$@"; do
2223
case "$arg" in
@@ -38,6 +39,9 @@ for arg in "$@"; do
3839
--s3compatsigv4-inst)
3940
S3COMPATSIGV4_INST=true
4041
;;
42+
--wiki)
43+
WIKI=true
44+
;;
4145
*)
4246
echo "Unknown argument: ${arg}" >&2
4347
exit 1
@@ -195,4 +199,16 @@ s3compatsigv4_inst_bucket: '${S3COMPATSIGV4_INST_BUCKET}'
195199
EOF
196200
fi
197201

202+
if [[ "${WIKI}" == "true" ]]; then
203+
cat >> "${OUTPUT}" <<'EOF'
204+
205+
wiki_enabled: true
206+
EOF
207+
else
208+
cat >> "${OUTPUT}" <<'EOF'
209+
210+
wiki_enabled: false
211+
EOF
212+
fi
213+
198214
cat "${OUTPUT}"

.github/scripts/setup_rdm.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,18 @@ create_docker_override() {
232232
local mfr_image="${MFR_IMAGE:-niicloudoperation/rdm-modular-file-renderer:latest}"
233233
local wb_image="${WB_IMAGE:-niicloudoperation/rdm-waterbutler:latest}"
234234
local elasticsearch_image="${ELASTICSEARCH_IMAGE:-elasticsearch:2}"
235-
235+
local y_websocket_url="${Y_WEBSOCKET_URL:-}"
236+
236237
echo "Creating docker-compose override with:"
237238
echo " OSF: $osf_image"
238239
echo " Ember: $ember_image"
239240
echo " CAS: $cas_image"
240241
echo " MFR: $mfr_image"
241242
echo " WaterButler: $wb_image"
242243
echo " Elasticsearch: $elasticsearch_image"
244+
if [ -n "$y_websocket_url" ]; then
245+
echo " Y-WebSocket: $y_websocket_url"
246+
fi
243247

244248
cat > docker-compose.override.yml << EOL
245249
# NII Cloud Operation images override
@@ -275,6 +279,7 @@ services:
275279
environment:
276280
OAUTHLIB_INSECURE_TRANSPORT: '1'
277281
KAKEN_ELASTIC_URI: http://kaken_elasticsearch:9200
282+
Y_WEBSOCKET_URL: '${y_websocket_url}'
278283
worker:
279284
image: ${osf_image}
280285
environment:

.github/scripts/setup_test_data.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import os
12
from django.utils import timezone
23
from osf.models import OSFUser, Node, Institution
34

5+
WIKI_ENABLED = os.environ.get('WIKI_ENABLED', 'false').lower() == 'true'
6+
47
INSTITUTION_NAME = 'Virginia Tech [Test]'
58

69
test_users = [
@@ -45,6 +48,42 @@
4548
},
4649
]
4750

51+
def create_rdmuserkey(user):
52+
# このスクリプトは `manage.py shell < file` で exec されるため、
53+
# 関数内で使うシンボルは関数内で import する(トップレベル import は関数から見えない)
54+
import hashlib
55+
from django.utils import timezone
56+
from osf.models.rdm_user_key import RdmUserKey
57+
58+
PRIVATE_KEY_VALUE = 1
59+
PUBLIC_KEY_VALUE = 2
60+
61+
if RdmUserKey.objects.filter(guid=user.id).exists():
62+
print(f"RdmUserKey already exists for user: {user.username}")
63+
return
64+
65+
now = timezone.now()
66+
date_hash = hashlib.md5(now.strftime('%Y%m%d%H%M%S').encode('utf-8')).hexdigest()
67+
pvt_key_name = f'{user._id}_{date_hash}_pvt.pem'
68+
pub_key_name = f'{user._id}_{date_hash}_pub.pem'
69+
70+
pvt_key = RdmUserKey()
71+
pvt_key.guid = user.id
72+
pvt_key.key_name = pvt_key_name
73+
pvt_key.key_kind = PRIVATE_KEY_VALUE
74+
pvt_key.created_time = now
75+
pvt_key.save()
76+
77+
pub_key = RdmUserKey()
78+
pub_key.guid = user.id
79+
pub_key.key_name = pub_key_name
80+
pub_key.key_kind = PUBLIC_KEY_VALUE
81+
pub_key.created_time = now
82+
pub_key.save()
83+
84+
print(f"Created RdmUserKey (pvt+pub) for user: {user.username}")
85+
86+
4887
for user_data in test_users:
4988
username = user_data['username']
5089
if not OSFUser.objects.filter(username=username).exists():
@@ -93,6 +132,10 @@
93132
user.emails.create(address=username)
94133
print(f"Created test user: {username}")
95134

135+
# Create user key (only needed when Wiki is enabled)
136+
if WIKI_ENABLED:
137+
create_rdmuserkey(user)
138+
96139
# Create a project for the new user
97140
project = Node(
98141
title=f"Test Project for {user_data['fullname']}",
@@ -109,6 +152,11 @@
109152
print(f"Test user already exists: {username}")
110153
# Ensure existing user has at least one project
111154
user = OSFUser.objects.get(username=username)
155+
156+
# Create user key (only needed when Wiki is enabled)
157+
if WIKI_ENABLED:
158+
create_rdmuserkey(user)
159+
112160
if not user.nodes.filter(category='project').exists():
113161
project = Node(
114162
title=f"Test Project for {user.fullname}",

0 commit comments

Comments
 (0)