Removed /config endpoint
This commit is contained in:
parent
053b684f3a
commit
658c23e70d
4 changed files with 38 additions and 34 deletions
|
@ -18,6 +18,7 @@
|
||||||
- The `/thumbnail` endpoint supports a new size labeled `tiny` which returns 40x40px images.
|
- The `/thumbnail` endpoint supports a new size labeled `tiny` which returns 40x40px images.
|
||||||
- Persistent data, such as playlists, is now saved in a directory that may be configured with the `--data` CLI option or the `POLARIS_DATA_DIR` environment variable.
|
- Persistent data, such as playlists, is now saved in a directory that may be configured with the `--data` CLI option or the `POLARIS_DATA_DIR` environment variable.
|
||||||
- Removed last.fm integration due to maintenance concerns (abandoned libraries, broken account linking) and mismatch with project goals.
|
- Removed last.fm integration due to maintenance concerns (abandoned libraries, broken account linking) and mismatch with project goals.
|
||||||
|
- Removed `/config` API endpoint.
|
||||||
|
|
||||||
### Web client
|
### Web client
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use axum_range::{KnownSize, Ranged};
|
||||||
use tower_http::{compression::CompressionLayer, CompressionLevel};
|
use tower_http::{compression::CompressionLayer, CompressionLevel};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{config, ddns, index, peaks, playlist, scanner, settings, thumbnail, user, vfs, App},
|
app::{ddns, index, peaks, playlist, scanner, settings, thumbnail, user, vfs, App},
|
||||||
server::{
|
server::{
|
||||||
dto, error::APIError, APIMajorVersion, API_ARRAY_SEPARATOR, API_MAJOR_VERSION,
|
dto, error::APIError, APIMajorVersion, API_ARRAY_SEPARATOR, API_MAJOR_VERSION,
|
||||||
API_MINOR_VERSION,
|
API_MINOR_VERSION,
|
||||||
|
@ -28,7 +28,6 @@ pub fn router() -> Router<App> {
|
||||||
.route("/initial_setup", get(get_initial_setup))
|
.route("/initial_setup", get(get_initial_setup))
|
||||||
.route("/auth", post(post_auth))
|
.route("/auth", post(post_auth))
|
||||||
// Configuration
|
// Configuration
|
||||||
.route("/config", put(put_config))
|
|
||||||
.route("/settings", get(get_settings))
|
.route("/settings", get(get_settings))
|
||||||
.route("/settings", put(put_settings))
|
.route("/settings", put(put_settings))
|
||||||
.route("/mount_dirs", get(get_mount_dirs))
|
.route("/mount_dirs", get(get_mount_dirs))
|
||||||
|
@ -101,15 +100,6 @@ async fn get_initial_setup(
|
||||||
Ok(Json(initial_setup))
|
Ok(Json(initial_setup))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn put_config(
|
|
||||||
_admin_rights: AdminRights,
|
|
||||||
State(config_manager): State<config::Manager>,
|
|
||||||
Json(config): Json<dto::Config>,
|
|
||||||
) -> Result<(), APIError> {
|
|
||||||
config_manager.apply(&config.into()).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_settings(
|
async fn get_settings(
|
||||||
State(settings_manager): State<settings::Manager>,
|
State(settings_manager): State<settings::Manager>,
|
||||||
_admin_rights: AdminRights,
|
_admin_rights: AdminRights,
|
||||||
|
|
|
@ -65,28 +65,41 @@ pub trait TestService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn complete_initial_setup(&mut self) {
|
async fn complete_initial_setup(&mut self) {
|
||||||
let configuration = dto::Config {
|
assert_eq!(
|
||||||
users: Some(vec![
|
self.fetch(&protocol::put_mount_dirs(vec![dto::MountDir {
|
||||||
dto::NewUser {
|
|
||||||
name: TEST_USERNAME_ADMIN.into(),
|
|
||||||
password: TEST_PASSWORD_ADMIN.into(),
|
|
||||||
admin: true,
|
|
||||||
},
|
|
||||||
dto::NewUser {
|
|
||||||
name: TEST_USERNAME.into(),
|
|
||||||
password: TEST_PASSWORD.into(),
|
|
||||||
admin: false,
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
mount_dirs: Some(vec![dto::MountDir {
|
|
||||||
name: TEST_MOUNT_NAME.into(),
|
name: TEST_MOUNT_NAME.into(),
|
||||||
source: TEST_MOUNT_SOURCE.into(),
|
source: TEST_MOUNT_SOURCE.into(),
|
||||||
}]),
|
}]))
|
||||||
..Default::default()
|
.await
|
||||||
};
|
.status(),
|
||||||
let request = protocol::apply_config(configuration);
|
StatusCode::OK
|
||||||
let response = self.fetch(&request).await;
|
);
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
|
||||||
|
assert_eq!(
|
||||||
|
self.fetch(&protocol::create_user(dto::NewUser {
|
||||||
|
name: TEST_USERNAME_ADMIN.into(),
|
||||||
|
password: TEST_PASSWORD_ADMIN.into(),
|
||||||
|
admin: true,
|
||||||
|
}))
|
||||||
|
.await
|
||||||
|
.status(),
|
||||||
|
StatusCode::OK
|
||||||
|
);
|
||||||
|
|
||||||
|
self.login_admin().await;
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
self.fetch(&protocol::create_user(dto::NewUser {
|
||||||
|
name: TEST_USERNAME.into(),
|
||||||
|
password: TEST_PASSWORD.into(),
|
||||||
|
admin: false,
|
||||||
|
}))
|
||||||
|
.await
|
||||||
|
.status(),
|
||||||
|
StatusCode::OK
|
||||||
|
);
|
||||||
|
|
||||||
|
self.logout().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn login_internal(&mut self, username: &str, password: &str) {
|
async fn login_internal(&mut self, username: &str, password: &str) {
|
||||||
|
|
|
@ -68,11 +68,11 @@ pub fn login(username: &str, password: &str) -> Request<dto::Credentials> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_config(config: dto::Config) -> Request<dto::Config> {
|
pub fn put_mount_dirs(dirs: Vec<dto::MountDir>) -> Request<Vec<dto::MountDir>> {
|
||||||
Request::builder()
|
Request::builder()
|
||||||
.method(Method::PUT)
|
.method(Method::PUT)
|
||||||
.uri("/api/config")
|
.uri("/api/mount_dirs")
|
||||||
.body(config)
|
.body(dirs)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue