Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
39 lines
1.6 KiB
Go
39 lines
1.6 KiB
Go
package store
|
|
|
|
import (
|
|
"database/sql"
|
|
"testing"
|
|
|
|
_ "modernc.org/sqlite"
|
|
)
|
|
|
|
func TestDomainLinkRequiresAbsoluteCrossDomainOrigin(t *testing.T) {
|
|
db, err := sql.Open("sqlite", "file:domain-links-test?mode=memory&cache=shared")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { _ = db.Close() })
|
|
if _, err := db.Exec(`
|
|
CREATE TABLE campuses(id INTEGER PRIMARY KEY,uuid TEXT,name TEXT,title TEXT,default_lang TEXT,authority_mode TEXT,fqdn TEXT,controller_transport TEXT,last_contact_at INTEGER,last_contact_error TEXT,enabled INTEGER,created_at INTEGER);
|
|
CREATE TABLE domains(id INTEGER PRIMARY KEY,uuid TEXT,name TEXT,title TEXT,domain TEXT,enabled INTEGER,created_at INTEGER,campus_uuid TEXT,placement TEXT,instance_fqdn TEXT,instance_fingerprint TEXT);
|
|
INSERT INTO campuses VALUES(1,'campus','main','Main','en','standalone','example.test','https',0,'',1,0);
|
|
INSERT INTO domains VALUES(1,'source','source','Source','',1,0,'campus','local','','');
|
|
INSERT INTO domains VALUES(2,'dest','dest','Destination','engineering',1,0,'campus','local','','');
|
|
`); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
st := &Store{DB: db}
|
|
local, err := st.DomainLink("source", "source", "/guide", "https")
|
|
if err != nil || local != "/guide" {
|
|
t.Fatalf("local=%q err=%v", local, err)
|
|
}
|
|
remote, err := st.DomainLink("source", "dest", "/guide", "https")
|
|
if err != nil || remote != "https://engineering.example.test/guide" {
|
|
t.Fatalf("remote=%q err=%v", remote, err)
|
|
}
|
|
object, err := st.DomainLink("source", "dest", "uuid:abc", "https")
|
|
if err != nil || object != "https://engineering.example.test/o/uuid:abc" {
|
|
t.Fatalf("object=%q err=%v", object, err)
|
|
}
|
|
}
|