mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-10-10 13:03:09 +08:00
0a9e71ae67
* feat(drivers/139): merge multiple share roots * fix(drivers/139): fallback to share preview without account * chore(drivers/139): address share review comments * refactor(drivers/139): reuse crypto Signed-off-by: MadDogOwner <xiaoran@xrgzs.top> * docs(drivers/139): add share support Signed-off-by: MadDogOwner <xiaoran@xrgzs.top> --------- Signed-off-by: MadDogOwner <xiaoran@xrgzs.top> Co-authored-by: syscc <syscc@users.noreply.github.com> Co-authored-by: MadDogOwner <xiaoran@xrgzs.top>
36 lines
933 B
Go
36 lines
933 B
Go
package _139
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestShareEntriesAndRefEncoding(t *testing.T) {
|
|
d := &Yun139{Addition: Addition{
|
|
Type: MetaShare,
|
|
LinkID: "share-a,share-b,share-c#pass",
|
|
}}
|
|
|
|
entries := d.shareEntries()
|
|
if len(entries) != 3 {
|
|
t.Fatalf("expected 3 share entries, got %d", len(entries))
|
|
}
|
|
if entries[2].LinkID != "share-c" || entries[2].Password != "pass" {
|
|
t.Fatalf("unexpected password share entry: %+v", entries[2])
|
|
}
|
|
|
|
refs := []shareRef{
|
|
{LinkID: entries[0].LinkID, Password: entries[0].Password, NodeID: "root-a"},
|
|
{LinkID: entries[2].LinkID, Password: entries[2].Password, NodeID: "root-b"},
|
|
}
|
|
encoded := encodeShareRefs(refs)
|
|
decoded, ok := decodeShareRefs(encoded)
|
|
if !ok || len(decoded) != len(refs) {
|
|
t.Fatalf("failed to decode merged share refs: %q", encoded)
|
|
}
|
|
for i := range refs {
|
|
if decoded[i] != refs[i] {
|
|
t.Fatalf("unexpected decoded ref at %d: %+v", i, decoded[i])
|
|
}
|
|
}
|
|
}
|