@@ -78,4 +78,104 @@ public function adminSettingsRequestReturned() {
7878 $ this ->httpResponse ->getBody ()->getContents (),
7979 );
8080 }
81+
82+ #[When('a user uploads a system configuration file ' )]
83+ public function userUploadsSystemConfigFile () {
84+ $ this ->serverContext ->actingAsUser ('user1 ' );
85+
86+ $ settingsAccessToken = $ this ->getSettingsAccessToken ('user ' );
87+ $ postOptions = [
88+ 'query ' => [
89+ 'access_token ' => $ settingsAccessToken ,
90+ 'fileId ' => '/settings/systemconfig/wordbook/poc.dic ' ,
91+ ],
92+ 'body ' => 'fake dictionary ' ,
93+ ];
94+
95+ $ options = array_merge ($ this ->serverContext ->getWebOptions (), $ postOptions );
96+
97+ $ this ->httpResponse = $ this ->http ->post ('wopi/settings/upload ' , $ options );
98+ }
99+
100+ #[When('an admin uploads a system configuration file ' )]
101+ public function adminUploadsSystemConfigFile () {
102+ $ this ->serverContext ->actAsAdmin (function () {
103+ $ settingsAccessToken = $ this ->getSettingsAccessToken ('admin ' );
104+ $ postOptions = [
105+ 'query ' => [
106+ 'access_token ' => $ settingsAccessToken ,
107+ 'fileId ' => '/settings/systemconfig/wordbook/poc.dic ' ,
108+ ],
109+ 'body ' => 'fake dictionary ' ,
110+ ];
111+
112+ $ options = array_merge ($ this ->serverContext ->getWebOptions (), $ postOptions );
113+
114+ $ this ->httpResponse = $ this ->http ->post ('wopi/settings/upload ' , $ options );
115+ });
116+ }
117+
118+ #[When('a user deletes a system configuration file ' )]
119+ public function userDeletesSystemConfigFile () {
120+ $ this ->serverContext ->actingAsUser ('user1 ' );
121+
122+ $ settingsAccessToken = $ this ->getSettingsAccessToken ('user ' );
123+ $ deleteOptions = [
124+ 'query ' => [
125+ 'access_token ' => $ settingsAccessToken ,
126+ 'fileId ' => '/settings/systemconfig/wordbook/poc.dic ' ,
127+ ],
128+ ];
129+
130+ $ options = array_merge ($ this ->serverContext ->getWebOptions (), $ deleteOptions );
131+
132+ $ this ->httpResponse = $ this ->http ->delete ('wopi/settings ' , $ options );
133+ }
134+
135+ #[When('an admin deletes a system configuration file ' )]
136+ public function adminDeletesSystemConfigFile () {
137+ $ this ->serverContext ->actAsAdmin (function () {
138+ $ settingsAccessToken = $ this ->getSettingsAccessToken ('admin ' );
139+ $ deleteOptions = [
140+ 'query ' => [
141+ 'access_token ' => $ settingsAccessToken ,
142+ 'fileId ' => '/settings/systemconfig/wordbook/poc.dic ' ,
143+ ],
144+ ];
145+
146+ $ options = array_merge ($ this ->serverContext ->getWebOptions (), $ deleteOptions );
147+
148+ $ this ->httpResponse = $ this ->http ->delete ('wopi/settings ' , $ options );
149+ });
150+ }
151+
152+ #[Then('the system configuration upload is forbidden ' )]
153+ public function systemConfigUploadForbidden () {
154+ Assert::assertEquals (403 , $ this ->httpResponse ->getStatusCode ());
155+ }
156+
157+ #[Then('the system configuration upload is allowed ' )]
158+ public function systemConfigUploadAllowed () {
159+ Assert::assertEquals (200 , $ this ->httpResponse ->getStatusCode ());
160+ }
161+
162+ #[Then('the system configuration deletion is forbidden ' )]
163+ public function systemConfigDeletionForbidden () {
164+ Assert::assertEquals (403 , $ this ->httpResponse ->getStatusCode ());
165+ }
166+
167+ #[Then('the system configuration deletion is allowed ' )]
168+ public function systemConfigDeletionAllowed () {
169+ Assert::assertEquals (200 , $ this ->httpResponse ->getStatusCode ());
170+ }
171+
172+ private function getSettingsAccessToken (string $ type ) {
173+ $ options = $ this ->serverContext ->getWebOptions ();
174+
175+ $ response = $ this ->http ->get ("settings/generateToken/ $ type " , $ options );
176+ $ responseBody = $ response ->getBody ()->getContents ();
177+ $ responseJson = json_decode ($ responseBody , true );
178+
179+ return $ responseJson ['token ' ];
180+ }
81181}
0 commit comments