mirror of
https://github.com/harivansh-afk/betterNAS.git
synced 2026-04-16 05:03:30 +00:00
ui
This commit is contained in:
parent
171a682f6a
commit
f6069a024a
7 changed files with 675 additions and 120 deletions
|
|
@ -56,8 +56,9 @@ func TestControlPlaneBinaryMountLoopIntegration(t *testing.T) {
|
|||
mount := postJSONAuth[mountProfile](t, client, controlPlane.sessionToken, controlPlane.baseURL+"/api/v1/mount-profiles/issue", mountProfileRequest{
|
||||
ExportID: export.ID,
|
||||
})
|
||||
if mount.MountURL != nodeAgent.baseURL+defaultWebDAVPath {
|
||||
t.Fatalf("expected runtime mount URL %q, got %q", nodeAgent.baseURL+defaultWebDAVPath, mount.MountURL)
|
||||
expectedMountURL := nodeAgent.baseURL + defaultWebDAVPath + runtimeUsername + "/"
|
||||
if mount.MountURL != expectedMountURL {
|
||||
t.Fatalf("expected runtime mount URL %q, got %q", expectedMountURL, mount.MountURL)
|
||||
}
|
||||
if mount.Credential.Mode != mountCredentialModeBasicAuth {
|
||||
t.Fatalf("expected mount credential mode %q, got %q", mountCredentialModeBasicAuth, mount.Credential.Mode)
|
||||
|
|
@ -103,11 +104,13 @@ func TestControlPlaneBinaryMultiExportProfilesStayDistinct(t *testing.T) {
|
|||
if firstMount.MountURL == secondMount.MountURL {
|
||||
t.Fatalf("expected distinct runtime mount URLs, got %q", firstMount.MountURL)
|
||||
}
|
||||
if firstMount.MountURL != nodeAgent.baseURL+firstMountPath {
|
||||
t.Fatalf("expected first runtime mount URL %q, got %q", nodeAgent.baseURL+firstMountPath, firstMount.MountURL)
|
||||
expectedFirstMountURL := nodeAgent.baseURL + firstMountPath + runtimeUsername + "/"
|
||||
expectedSecondMountURL := nodeAgent.baseURL + secondMountPath + runtimeUsername + "/"
|
||||
if firstMount.MountURL != expectedFirstMountURL {
|
||||
t.Fatalf("expected first runtime mount URL %q, got %q", expectedFirstMountURL, firstMount.MountURL)
|
||||
}
|
||||
if secondMount.MountURL != nodeAgent.baseURL+secondMountPath {
|
||||
t.Fatalf("expected second runtime mount URL %q, got %q", nodeAgent.baseURL+secondMountPath, secondMount.MountURL)
|
||||
if secondMount.MountURL != expectedSecondMountURL {
|
||||
t.Fatalf("expected second runtime mount URL %q, got %q", expectedSecondMountURL, secondMount.MountURL)
|
||||
}
|
||||
|
||||
assertHTTPStatusWithBasicAuth(t, client, "PROPFIND", firstMount.MountURL, controlPlane.username, controlPlane.password, http.StatusMultiStatus)
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ func (a *app) handleMountProfileIssue(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
mountURL, err := buildMountURL(context)
|
||||
mountURL, err := buildMountURL(context, currentUser.Username)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusServiceUnavailable)
|
||||
return
|
||||
|
|
@ -720,13 +720,17 @@ func hasConfiguredNextcloudBaseURL(baseURL string) bool {
|
|||
return err == nil
|
||||
}
|
||||
|
||||
func buildMountURL(context exportContext) (string, error) {
|
||||
func buildMountURL(context exportContext, username string) (string, error) {
|
||||
address, ok := firstAddress(context.node.DirectAddress, context.node.RelayAddress)
|
||||
if !ok {
|
||||
return "", errMountTargetUnavailable
|
||||
}
|
||||
|
||||
mountURL, err := buildAbsoluteHTTPURLWithPath(address, mountProfilePathForExport(context.export.MountPath))
|
||||
basePath := mountProfilePathForExport(context.export.MountPath)
|
||||
// Append the username so Finder uses it as the volume name in the sidebar.
|
||||
userScopedPath := path.Join(basePath, username) + "/"
|
||||
|
||||
mountURL, err := buildAbsoluteHTTPURLWithPath(address, userScopedPath)
|
||||
if err != nil {
|
||||
return "", errMountTargetUnavailable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ func TestControlPlaneRegistrationProfilesAndHeartbeat(t *testing.T) {
|
|||
if mount.DisplayName != "Photos" {
|
||||
t.Fatalf("expected mount display name Photos, got %q", mount.DisplayName)
|
||||
}
|
||||
if mount.MountURL != "http://nas.local:8090/dav/" {
|
||||
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/", mount.MountURL)
|
||||
if mount.MountURL != "http://nas.local:8090/dav/fixture/" {
|
||||
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/fixture/", mount.MountURL)
|
||||
}
|
||||
if mount.Readonly {
|
||||
t.Fatal("expected mount profile to be read-write")
|
||||
|
|
@ -415,11 +415,11 @@ func TestControlPlaneProfilesRemainExportSpecificForConfiguredMountPaths(t *test
|
|||
if docsMount.MountURL == mediaMount.MountURL {
|
||||
t.Fatalf("expected distinct mount URLs for configured export paths, got %q", docsMount.MountURL)
|
||||
}
|
||||
if docsMount.MountURL != "http://nas.local:8090/dav/exports/docs/" {
|
||||
t.Fatalf("expected docs mount URL %q, got %q", "http://nas.local:8090/dav/exports/docs/", docsMount.MountURL)
|
||||
if docsMount.MountURL != "http://nas.local:8090/dav/exports/docs/fixture/" {
|
||||
t.Fatalf("expected docs mount URL %q, got %q", "http://nas.local:8090/dav/exports/docs/fixture/", docsMount.MountURL)
|
||||
}
|
||||
if mediaMount.MountURL != "http://nas.local:8090/dav/exports/media/" {
|
||||
t.Fatalf("expected media mount URL %q, got %q", "http://nas.local:8090/dav/exports/media/", mediaMount.MountURL)
|
||||
if mediaMount.MountURL != "http://nas.local:8090/dav/exports/media/fixture/" {
|
||||
t.Fatalf("expected media mount URL %q, got %q", "http://nas.local:8090/dav/exports/media/fixture/", mediaMount.MountURL)
|
||||
}
|
||||
|
||||
docsCloud := postJSONAuth[cloudProfile](t, server.Client(), testClientToken, server.URL+"/api/v1/cloud-profiles/issue", cloudProfileRequest{
|
||||
|
|
@ -469,8 +469,8 @@ func TestControlPlaneMountProfilesUseRelayAndPreserveBasePath(t *testing.T) {
|
|||
})
|
||||
|
||||
mount := postJSONAuth[mountProfile](t, server.Client(), testClientToken, server.URL+"/api/v1/mount-profiles/issue", mountProfileRequest{ExportID: "dev-export"})
|
||||
if mount.MountURL != "https://nas.example.test/control/dav/relay/" {
|
||||
t.Fatalf("expected relay mount URL %q, got %q", "https://nas.example.test/control/dav/relay/", mount.MountURL)
|
||||
if mount.MountURL != "https://nas.example.test/control/dav/relay/fixture/" {
|
||||
t.Fatalf("expected relay mount URL %q, got %q", "https://nas.example.test/control/dav/relay/fixture/", mount.MountURL)
|
||||
}
|
||||
|
||||
registration = registerNode(t, server.Client(), server.URL+"/api/v1/nodes/register", testNodeBootstrapToken, nodeRegistrationRequest{
|
||||
|
|
@ -648,8 +648,8 @@ func TestControlPlanePersistsRegistryAcrossAppRestart(t *testing.T) {
|
|||
}
|
||||
|
||||
mount := postJSONAuth[mountProfile](t, secondServer.Client(), testClientToken, secondServer.URL+"/api/v1/mount-profiles/issue", mountProfileRequest{ExportID: exports[0].ID})
|
||||
if mount.MountURL != "http://nas.local:8090/dav/persisted/" {
|
||||
t.Fatalf("expected persisted mount URL %q, got %q", "http://nas.local:8090/dav/persisted/", mount.MountURL)
|
||||
if mount.MountURL != "http://nas.local:8090/dav/persisted/fixture/" {
|
||||
t.Fatalf("expected persisted mount URL %q, got %q", "http://nas.local:8090/dav/persisted/fixture/", mount.MountURL)
|
||||
}
|
||||
|
||||
reRegistration := registerNode(t, secondServer.Client(), secondServer.URL+"/api/v1/nodes/register", registration.NodeToken, nodeRegistrationRequest{
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ func TestSQLiteRegistrationAndExports(t *testing.T) {
|
|||
}
|
||||
|
||||
mount := postJSONAuth[mountProfile](t, server.Client(), testClientToken, server.URL+"/api/v1/mount-profiles/issue", mountProfileRequest{ExportID: "dev-export"})
|
||||
if mount.MountURL != "http://nas.local:8090/dav/docs/" {
|
||||
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/docs/", mount.MountURL)
|
||||
if mount.MountURL != "http://nas.local:8090/dav/docs/fixture/" {
|
||||
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/docs/fixture/", mount.MountURL)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue