|
1 | 1 | use crate::common::client::Client; |
2 | | -use crate::common::contexts::settings::form::UpdateSettingsForm; |
3 | 2 | use crate::common::contexts::settings::responses::{AllSettingsResponse, Public, PublicSettingsResponse, SiteNameResponse}; |
4 | | -use crate::common::contexts::settings::{Auth, Database, ImageCache, Mail, Net, Settings, Tracker, Website}; |
5 | 3 | use crate::e2e::contexts::user::steps::new_logged_in_admin; |
6 | 4 | use crate::e2e::environment::TestEnv; |
7 | 5 |
|
@@ -69,106 +67,27 @@ async fn it_should_allow_admins_to_get_all_the_settings() { |
69 | 67 | #[tokio::test] |
70 | 68 | async fn it_should_allow_admins_to_update_all_the_settings() { |
71 | 69 | let mut env = TestEnv::new(); |
| 70 | + |
| 71 | + if !env.is_isolated() { |
| 72 | + // This test can't be executed in a non-isolated environment because |
| 73 | + // it will change the settings for all the other tests. |
| 74 | + return; |
| 75 | + } |
| 76 | + |
72 | 77 | env.start().await; |
73 | 78 |
|
74 | 79 | let logged_in_admin = new_logged_in_admin(&env).await; |
75 | 80 | let client = Client::authenticated(&env.server_socket_addr().unwrap(), &logged_in_admin.token); |
76 | 81 |
|
77 | | - // todo: we can't actually change the settings because it would affect other E2E tests. |
78 | | - // Location for the `config.toml` file is hardcoded. We could use a ENV variable to change it. |
79 | | - |
80 | | - let response = client |
81 | | - .update_settings(UpdateSettingsForm { |
82 | | - website: Website { |
83 | | - name: "Torrust".to_string(), |
84 | | - }, |
85 | | - tracker: Tracker { |
86 | | - url: "udp://tracker:6969".to_string(), |
87 | | - mode: "Public".to_string(), |
88 | | - api_url: "http://tracker:1212".to_string(), |
89 | | - token: "MyAccessToken".to_string(), |
90 | | - token_valid_seconds: 7_257_600, |
91 | | - }, |
92 | | - net: Net { |
93 | | - port: 3000, |
94 | | - base_url: None, |
95 | | - }, |
96 | | - auth: Auth { |
97 | | - email_on_signup: "Optional".to_string(), |
98 | | - min_password_length: 6, |
99 | | - max_password_length: 64, |
100 | | - secret_key: "MaxVerstappenWC2021".to_string(), |
101 | | - }, |
102 | | - database: Database { |
103 | | - connect_url: "sqlite://storage/database/torrust_index_backend_e2e_testing.db?mode=rwc".to_string(), |
104 | | - torrent_info_update_interval: 3600, |
105 | | - }, |
106 | | - mail: Mail { |
107 | | - email_verification_enabled: false, |
108 | | - from: "[email protected]".to_string(), |
109 | | - reply_to: "[email protected]".to_string(), |
110 | | - username: String::new(), |
111 | | - password: String::new(), |
112 | | - server: "mailcatcher".to_string(), |
113 | | - port: 1025, |
114 | | - }, |
115 | | - image_cache: ImageCache { |
116 | | - max_request_timeout_ms: 1000, |
117 | | - capacity: 128_000_000, |
118 | | - entry_size_limit: 4_000_000, |
119 | | - user_quota_period_seconds: 3600, |
120 | | - user_quota_bytes: 64_000_000, |
121 | | - }, |
122 | | - }) |
123 | | - .await; |
| 82 | + let mut new_settings = env.server_settings().unwrap(); |
| 83 | + |
| 84 | + new_settings.website.name = "UPDATED NAME".to_string(); |
| 85 | + |
| 86 | + let response = client.update_settings(&new_settings).await; |
124 | 87 |
|
125 | 88 | let res: AllSettingsResponse = serde_json::from_str(&response.body).unwrap(); |
126 | 89 |
|
127 | | - assert_eq!( |
128 | | - res.data, |
129 | | - Settings { |
130 | | - website: Website { |
131 | | - name: "Torrust".to_string(), |
132 | | - }, |
133 | | - tracker: Tracker { |
134 | | - url: "udp://tracker:6969".to_string(), |
135 | | - mode: "Public".to_string(), |
136 | | - api_url: "http://tracker:1212".to_string(), |
137 | | - token: "MyAccessToken".to_string(), |
138 | | - token_valid_seconds: 7_257_600, |
139 | | - }, |
140 | | - net: Net { |
141 | | - port: 3000, |
142 | | - base_url: None, |
143 | | - }, |
144 | | - auth: Auth { |
145 | | - email_on_signup: "Optional".to_string(), |
146 | | - min_password_length: 6, |
147 | | - max_password_length: 64, |
148 | | - secret_key: "MaxVerstappenWC2021".to_string(), |
149 | | - }, |
150 | | - database: Database { |
151 | | - connect_url: "sqlite://storage/database/torrust_index_backend_e2e_testing.db?mode=rwc".to_string(), |
152 | | - torrent_info_update_interval: 3600, |
153 | | - }, |
154 | | - mail: Mail { |
155 | | - email_verification_enabled: false, |
156 | | - from : "[email protected]".to_string (), |
157 | | - reply_to : "[email protected]".to_string (), |
158 | | - username: String::new(), |
159 | | - password: String::new(), |
160 | | - server: "mailcatcher".to_string(), |
161 | | - port: 1025, |
162 | | - }, |
163 | | - image_cache: ImageCache { |
164 | | - max_request_timeout_ms: 1000, |
165 | | - capacity: 128_000_000, |
166 | | - entry_size_limit: 4_000_000, |
167 | | - user_quota_period_seconds: 3600, |
168 | | - user_quota_bytes: 64_000_000, |
169 | | - }, |
170 | | - } |
171 | | - ); |
| 90 | + assert_eq!(res.data, new_settings); |
172 | 91 | if let Some(content_type) = &response.content_type { |
173 | 92 | assert_eq!(content_type, "application/json"); |
174 | 93 | } |
|
0 commit comments