snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s

This commit is contained in:
upstream-mirror
2026-09-18 01:22:23 +05:00
commit 7e385fc126
8391 changed files with 1766236 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
package dal
import (
"context"
"testing"
"time"
"github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/pkg/dal"
)
func Test_dal_codec_alias(t *testing.T) {
t.Skip("needs refactoring")
model := &dal.Model{
Ident: "compose_record_partitioned",
Attributes: dal.AttributeSet{
&dal.Attribute{Ident: "ID", Type: &dal.TypeID{}, Store: &dal.CodecAlias{Ident: "id"}, PrimaryKey: true},
&dal.Attribute{Ident: "intr_vID", Type: &dal.TypeID{}, Store: &dal.CodecAlias{Ident: "vID"}},
&dal.Attribute{Ident: "intr_vRef", Type: &dal.TypeRef{}, Store: &dal.CodecAlias{Ident: "vRef"}},
&dal.Attribute{Ident: "intr_vTimestamp", Type: &dal.TypeTimestamp{}, Store: &dal.CodecAlias{Ident: "vTimestamp"}},
&dal.Attribute{Ident: "intr_vTime", Type: &dal.TypeTime{}, Store: &dal.CodecAlias{Ident: "vTime"}},
&dal.Attribute{Ident: "intr_vDate", Type: &dal.TypeDate{}, Store: &dal.CodecAlias{Ident: "vDate"}},
&dal.Attribute{Ident: "intr_vNumber", Type: &dal.TypeNumber{}, Store: &dal.CodecAlias{Ident: "vNumber"}},
&dal.Attribute{Ident: "intr_vText", Type: &dal.TypeText{}, Store: &dal.CodecAlias{Ident: "vText"}},
&dal.Attribute{Ident: "intr_vBoolean_T", Type: &dal.TypeBoolean{}, Store: &dal.CodecAlias{Ident: "vBoolean_T"}},
&dal.Attribute{Ident: "intr_vBoolean_F", Type: &dal.TypeBoolean{}, Store: &dal.CodecAlias{Ident: "vBoolean_F"}},
&dal.Attribute{Ident: "intr_vEnum", Type: &dal.TypeEnum{}, Store: &dal.CodecAlias{Ident: "vEnum"}},
&dal.Attribute{Ident: "intr_vGeometry", Type: &dal.TypeGeometry{}, Store: &dal.CodecAlias{Ident: "vGeometry"}},
&dal.Attribute{Ident: "intr_vJSON", Type: &dal.TypeJSON{}, Store: &dal.CodecAlias{Ident: "vJSON"}},
&dal.Attribute{Ident: "intr_vBlob", Type: &dal.TypeBlob{}, Store: &dal.CodecAlias{Ident: "vBlob"}},
&dal.Attribute{Ident: "intr_vUUID", Type: &dal.TypeUUID{}, Store: &dal.CodecAlias{Ident: "vUUID"}},
},
}
var (
rIn = types.Record{ID: 42, CreatedAt: time.Now()}
rOut = types.Record{}
)
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vID", Value: "34324"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vRef", Value: "32423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vTimestamp", Value: "2022-01-01T10:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vTime", Value: "04:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vDate", Value: "2022-01-01"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vNumber", Value: "2423423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vText", Value: "lorm ipsum "})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vBoolean_T", Value: "1"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vBoolean_F", Value: ""})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vEnum", Value: "abc"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vGeometry", Value: `{"lat":1,"lng":1}`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vJSON", Value: `[{"bool":true"}]`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vBlob", Value: "0110101"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "intr_vUUID", Value: "ba485865-54f9-44de-bde8-6965556c022a"})
bootstrap(t, func(ctx context.Context, t *testing.T, h helper, svc dal.FullService) {
h.cleanupDal()
_, err := svc.ReplaceModel(ctx, nil, model)
h.a.NoError(err)
h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(), &rIn))
h.a.NoError(svc.Lookup(ctx, model.ToFilter(), dal.LookupOperations(), dal.PKValues{"id": rIn.ID}, &rOut))
for _, inVal := range rIn.Values {
outVal := rOut.Values.Get(inVal.Name, 0)
h.a.Equal(inVal.Value, outVal.Value, "field", inVal.Name)
}
})
}

View File

@@ -0,0 +1,68 @@
package dal
import (
"context"
"testing"
"github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/pkg/dal"
)
func Test_dal_codec_json(t *testing.T) {
t.Skip("needs refactoring")
model := &dal.Model{
Ident: "compose_record",
Attributes: dal.AttributeSet{
&dal.Attribute{Ident: "ID", Type: &dal.TypeID{}, Store: &dal.CodecAlias{Ident: "id"}, PrimaryKey: true},
&dal.Attribute{Ident: "vID", Type: &dal.TypeID{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vRef", Type: &dal.TypeRef{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vTimestamp", Type: &dal.TypeTimestamp{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vTime", Type: &dal.TypeTime{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vDate", Type: &dal.TypeDate{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vNumber", Type: &dal.TypeNumber{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vText", Type: &dal.TypeText{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vBoolean_T", Type: &dal.TypeBoolean{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vBoolean_F", Type: &dal.TypeBoolean{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vEnum", Type: &dal.TypeEnum{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vGeometry", Type: &dal.TypeGeometry{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vJSON", Type: &dal.TypeJSON{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vBlob", Type: &dal.TypeBlob{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
&dal.Attribute{Ident: "vUUID", Type: &dal.TypeUUID{}, Store: &dal.CodecRecordValueSetJSON{Ident: "values"}},
},
}
var (
rIn = types.Record{ID: 42}
rOut = types.Record{}
)
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vID", Value: "34324"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vRef", Value: "32423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vTimestamp", Value: "2022-01-01T10:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vTime", Value: "04:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vDate", Value: "2022-01-01"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vNumber", Value: "2423423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vText", Value: "lorm ipsum "})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBoolean_T", Value: "1"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBoolean_F", Value: ""})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vEnum", Value: "abc"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vGeometry", Value: `{"lat":1,"lng":1}`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vJSON", Value: `[{"bool":true"}]`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBlob", Value: "0110101"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vUUID", Value: "ba485865-54f9-44de-bde8-6965556c022a"})
bootstrap(t, func(ctx context.Context, t *testing.T, h helper, svc dal.FullService) {
_, err := svc.ReplaceModel(ctx, nil, model)
h.a.NoError(err)
h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(), &rIn))
h.a.NoError(svc.Lookup(ctx, model.ToFilter(), dal.LookupOperations(), dal.PKValues{"id": rIn.ID}, &rOut))
for _, inVal := range rIn.Values {
outVal := rOut.Values.Get(inVal.Name, 0)
h.a.Equal(inVal.Value, outVal.Value, "field", inVal.Name)
}
})
}

View File

@@ -0,0 +1,141 @@
package dal
import (
"context"
"testing"
"github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/pkg/dal"
)
func Test_dal_codec_plain(t *testing.T) {
t.Skip("needs refactoring")
model := &dal.Model{
Ident: "compose_record_partitioned",
Attributes: dal.AttributeSet{
&dal.Attribute{Ident: "ID", Type: &dal.TypeID{}, Store: &dal.CodecAlias{Ident: "id"}, PrimaryKey: true},
&dal.Attribute{Ident: "vID", Type: &dal.TypeID{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vRef", Type: &dal.TypeRef{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vTimestamp", Type: &dal.TypeTimestamp{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vTime", Type: &dal.TypeTime{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vDate", Type: &dal.TypeDate{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vNumber", Type: &dal.TypeNumber{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vText", Type: &dal.TypeText{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vBoolean_T", Type: &dal.TypeBoolean{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vBoolean_F", Type: &dal.TypeBoolean{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vEnum", Type: &dal.TypeEnum{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vGeometry", Type: &dal.TypeGeometry{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vJSON", Type: &dal.TypeJSON{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vBlob", Type: &dal.TypeBlob{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vUUID", Type: &dal.TypeUUID{}, Store: &dal.CodecPlain{}},
},
}
var (
rIn = types.Record{ID: 42}
rOut = types.Record{}
)
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vID", Value: "34324"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vRef", Value: "32423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vTimestamp", Value: "2022-01-01T10:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vTime", Value: "04:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vDate", Value: "2022-01-01"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vNumber", Value: "2423423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vText", Value: "lorm ipsum "})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBoolean_T", Value: "1"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBoolean_F", Value: ""})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vEnum", Value: "abc"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vGeometry", Value: `{"lat":1,"lng":1}`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vJSON", Value: `[{"bool":true"}]`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBlob", Value: "0110101"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vUUID", Value: "ba485865-54f9-44de-bde8-6965556c022a"})
bootstrap(t, func(ctx context.Context, t *testing.T, h helper, svc dal.FullService) {
_, err := svc.ReplaceModel(ctx, nil, model)
h.a.NoError(err)
h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(), &rIn))
h.a.NoError(svc.Lookup(ctx, model.ToFilter(), dal.LookupOperations(), dal.PKValues{"id": rIn.ID}, &rOut))
for _, inVal := range rIn.Values {
outVal := rOut.Values.Get(inVal.Name, 0)
h.a.Equal(inVal.Value, outVal.Value, "field", inVal.Name)
}
})
}
func benchmark_dal_codec_plain(b *testing.B, count int) {
b.Skip("needs refactoring")
model := &dal.Model{
Ident: "compose_record_partitioned",
Attributes: dal.AttributeSet{
&dal.Attribute{Ident: "ID", Type: &dal.TypeID{}, Store: &dal.CodecAlias{Ident: "id"}, PrimaryKey: true},
&dal.Attribute{Ident: "vID", Type: &dal.TypeID{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vRef", Type: &dal.TypeRef{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vTimestamp", Type: &dal.TypeTimestamp{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vTime", Type: &dal.TypeTime{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vDate", Type: &dal.TypeDate{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vNumber", Type: &dal.TypeNumber{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vText", Type: &dal.TypeText{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vBoolean_T", Type: &dal.TypeBoolean{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vBoolean_F", Type: &dal.TypeBoolean{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vEnum", Type: &dal.TypeEnum{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vGeometry", Type: &dal.TypeGeometry{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vJSON", Type: &dal.TypeJSON{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vBlob", Type: &dal.TypeBlob{}, Store: &dal.CodecPlain{}},
&dal.Attribute{Ident: "vUUID", Type: &dal.TypeUUID{}, Store: &dal.CodecPlain{}},
},
}
var (
rIn = types.Record{ID: 42}
)
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vID", Value: "34324"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vRef", Value: "32423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vTimestamp", Value: "2022-01-01T10:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vTime", Value: "04:10:10"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vDate", Value: "2022-01-01"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vNumber", Value: "2423423"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vText", Value: "lorm ipsum "})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBoolean_T", Value: "true"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBoolean_F", Value: "false"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vEnum", Value: "abc"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vGeometry", Value: `{"lat":1,"lng":1}`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vJSON", Value: `[{"bool":true"}]`})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vBlob", Value: "0110101"})
rIn.Values = rIn.Values.Set(&types.RecordValue{Name: "vUUID", Value: "ba485865-54f9-44de-bde8-6965556c022a"})
bootstrapBenchmark(b, func(ctx context.Context, b *testing.B, h helper, svc dal.FullService) {
_, err := svc.ReplaceModel(ctx, nil, model)
h.a.NoError(err)
ctr := uint64(1)
for rep := 0; rep < b.N; rep++ {
insert := make([]dal.ValueGetter, 0, 100)
for i := 0; i < 100; i++ {
tmp := rIn
tmp.ID = ctr
ctr++
insert = append(insert, &tmp)
}
b.StartTimer()
h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(), insert...))
b.StopTimer()
}
})
}
func Benchmark_dal_codec_plain_1(b *testing.B) { benchmark_dal_codec_plain(b, 1) }
func Benchmark_dal_codec_plain_10(b *testing.B) { benchmark_dal_codec_plain(b, 10) }
func Benchmark_dal_codec_plain_100(b *testing.B) { benchmark_dal_codec_plain(b, 100) }
func Benchmark_dal_codec_plain_1000(b *testing.B) { benchmark_dal_codec_plain(b, 1000) }
func Benchmark_dal_codec_plain_10000(b *testing.B) { benchmark_dal_codec_plain(b, 10000) }

View File

@@ -0,0 +1,193 @@
package dal
import (
"encoding/json"
"fmt"
"net/http"
"testing"
"time"
"github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/tests/helpers"
)
func Test_dal_crud_compose_record_create(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
ctx := h.secCtx()
helpers.AllowMeModuleCRUD(h)
helpers.AllowMeRecordCRUD(h)
ns := h.createNamespace("test")
module := createModuleFromGenerics(ctx, t, "ok_module.json", ns.ID, &types.ModuleConfig{
DAL: types.ModuleConfigDAL{
ConnectionID: 0,
},
})
// create
h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d/record/", ns.ID, module.ID)).
Body(loadRequestFromGenerics(t, "ok_record.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
rsp := h.apiInit().
Get(fmt.Sprintf("/compose/namespace/%d/module/%d/record/", ns.ID, module.ID)).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
aux := composeRecordSearchRestRsp{}
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
r := aux.Response.Set[0]
h.a.NotEqual(uint64(0), r.ID)
h.a.Equal(module.ID, r.ModuleID)
h.a.Equal(module.NamespaceID, r.NamespaceID)
h.a.Equal(h.cUser.ID, r.OwnedBy)
h.a.NotEqual(time.Time{}, r.CreatedAt)
h.a.Equal(h.cUser.ID, r.CreatedBy)
h.a.Nil(r.UpdatedAt)
h.a.Equal(uint64(0), r.UpdatedBy)
h.a.Nil(r.DeletedAt)
h.a.Equal(uint64(0), r.DeletedBy)
h.a.Equal("me@test.tld", r.Values.Get("email", 0).Value)
h.a.Equal("Me", r.Values.Get("name", 0).Value)
h.a.Equal("42", r.Values.Get("a_number", 0).Value)
}
func Test_dal_crud_compose_record_update(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
ctx := h.secCtx()
helpers.AllowMeModuleCRUD(h)
helpers.AllowMeRecordCRUD(h)
ns := h.createNamespace("test")
module := createModuleFromGenerics(ctx, t, "ok_module.json", ns.ID, &types.ModuleConfig{
DAL: types.ModuleConfigDAL{
ConnectionID: 0,
},
})
record := createRecordFromGenerics(ctx, t, "ok_record.json", ns.ID, module.ID)
h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d/record/%d", ns.ID, module.ID, record.ID)).
Body(loadRequestFromGenerics(t, "ok_record_update.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
rsp := h.apiInit().
Get(fmt.Sprintf("/compose/namespace/%d/module/%d/record/", ns.ID, module.ID)).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
aux := composeRecordSearchRestRsp{}
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
r := aux.Response.Set[0]
h.a.NotEqual(uint64(0), r.ID)
h.a.Equal(module.ID, r.ModuleID)
h.a.Equal(module.NamespaceID, r.NamespaceID)
h.a.Equal(h.cUser.ID, r.OwnedBy)
h.a.NotEqual(time.Time{}, r.CreatedAt)
h.a.Equal(h.cUser.ID, r.CreatedBy)
h.a.NotNil(r.UpdatedAt)
h.a.Equal(h.cUser.ID, r.UpdatedBy)
h.a.Nil(r.DeletedAt)
h.a.Equal(uint64(0), r.DeletedBy)
h.a.Equal("me+updated@test.tld", r.Values.Get("email", 0).Value)
h.a.Equal("Me updated", r.Values.Get("name", 0).Value)
h.a.Equal("43", r.Values.Get("a_number", 0).Value)
}
func Test_dal_crud_compose_record_delete(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
ctx := h.secCtx()
helpers.AllowMeModuleCRUD(h)
helpers.AllowMeRecordCRUD(h)
ns := h.createNamespace("test")
module := createModuleFromGenerics(ctx, t, "ok_module.json", ns.ID, &types.ModuleConfig{
DAL: types.ModuleConfigDAL{
ConnectionID: 0,
},
})
record := createRecordFromGenerics(ctx, t, "ok_record.json", ns.ID, module.ID)
h.apiInit().
Delete(fmt.Sprintf("/compose/namespace/%d/module/%d/record/%d", ns.ID, module.ID, record.ID)).
Header("Accept", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
rsp := h.apiInit().
Get(fmt.Sprintf("/compose/namespace/%d/module/%d/record/%d", ns.ID, module.ID, record.ID)).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
aux := composeRecordRestRsp{}
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
r := aux.Response
h.a.NotEqual(uint64(0), r.ID)
h.a.Equal(module.ID, r.ModuleID)
h.a.Equal(module.NamespaceID, r.NamespaceID)
h.a.Equal(h.cUser.ID, r.OwnedBy)
h.a.NotEqual(time.Time{}, r.CreatedAt)
h.a.Equal(h.cUser.ID, r.CreatedBy)
h.a.Nil(r.UpdatedAt)
h.a.Equal(uint64(0), r.UpdatedBy)
h.a.NotNil(r.DeletedAt)
h.a.Equal(h.cUser.ID, r.DeletedBy)
}

View File

@@ -0,0 +1,189 @@
package dal
import (
"encoding/json"
"fmt"
"net/http"
"testing"
"github.com/cortezaproject/corteza/server/tests/helpers"
jsonpath "github.com/steinfletcher/apitest-jsonpath"
)
func Test_dal_crud_issues_compose_module_missing_sensitivity(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeModuleCRUD(h)
ns := h.createNamespace("test")
aux := &composeModuleRestRsp{}
rsp := h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/", ns.ID)).
Body(loadRequestFromGenerics(t, "nok_module_missing_sensitivity_level.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
rsp = h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Body(loadRequestFromGenerics(t, "ok_module.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
rsp = h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Body(loadRequestFromGenerics(t, "nok_module_missing_sensitivity_level.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
rsp = h.apiInit().
Delete(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Header("Accept", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.success.message")).
End()
}
func Test_dal_crud_issues_compose_module_field_missing_sensitivity(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeModuleCRUD(h)
ns := h.createNamespace("test")
aux := &composeModuleRestRsp{}
rsp := h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/", ns.ID)).
Body(loadRequestFromGenerics(t, "nok_module_missing_field_sensitivity_level.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
rsp = h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Body(loadRequestFromGenerics(t, "ok_module.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
rsp = h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Body(loadRequestFromGenerics(t, "nok_module_missing_field_sensitivity_level.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
rsp = h.apiInit().
Delete(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Header("Accept", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.success.message")).
End()
}
func Test_dal_crud_issues_compose_module_nok_connection(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeModuleCRUD(h)
helpers.AllowMeDalConnectionCRUD(h)
ns := h.createNamespace("test")
conn := createConnectionFromGenerics(h.secCtx(), t, "nok_connection_connectivity.json")
aux := &composeModuleRestRsp{}
rsp := h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/", ns.ID)).
Body(loadRequestFromScenarioWithConnection(t, "module.json", conn.ID)).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
h.apiInit().
Put(fmt.Sprintf("/system/dal/connections/%d", conn.ID)).
Body(loadRequestFromGenerics(t, "ok_connection.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.connectionID")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
rsp = h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Body(loadRequestFromScenarioWithConnection(t, "module.json", conn.ID)).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.moduleID")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
rsp = h.apiInit().
Delete(fmt.Sprintf("/compose/namespace/%d/module/%d", ns.ID, aux.Response.ID)).
Header("Accept", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
}

View File

@@ -0,0 +1,100 @@
package dal
import (
"fmt"
"net/http"
"testing"
"github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/tests/helpers"
)
func Test_dal_crud_issues_compose_record_nok_connection(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeDalConnectionCRUD(h)
helpers.AllowMeModuleCRUD(h)
helpers.AllowMeRecordCRUD(h)
ns := h.createNamespace("test")
connection := createConnectionFromGenerics(h.secCtx(), t, "nok_connection_connectivity.json")
module := createModuleFromGenerics(h.secCtx(), t, "ok_module.json", ns.ID, &types.ModuleConfig{
DAL: types.ModuleConfigDAL{
ConnectionID: connection.ID,
},
})
h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d/record/", ns.ID, module.ID)).
Body(loadRequestFromGenerics(t, "ok_record.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertErrorP(fmt.Sprintf("connection %d has issues", connection.ID))).
End()
}
func Test_dal_crud_issues_compose_record_nok_model(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeDalConnectionCRUD(h)
helpers.AllowMeModuleCRUD(h)
helpers.AllowMeRecordCRUD(h)
ns := h.createNamespace("test")
connection := createConnectionFromGenerics(h.secCtx(), t, "ok_connection.json")
module := createModuleFromGenerics(h.secCtx(), t, "nok_module_sensitivity_level.json", ns.ID, &types.ModuleConfig{
DAL: types.ModuleConfigDAL{
ConnectionID: connection.ID,
},
})
h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d/record/", ns.ID, module.ID)).
Body(loadRequestFromGenerics(t, "ok_record.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertErrorP(fmt.Sprintf("model %d has issues", module.ID))).
End()
}
func Test_dal_crud_issues_compose_record_ok(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeDalConnectionCRUD(h)
helpers.AllowMeModuleCRUD(h)
helpers.AllowMeRecordCRUD(h)
ns := h.createNamespace("test")
connection := createConnectionFromGenerics(h.secCtx(), t, "ok_connection.json")
module := createModuleFromGenerics(h.secCtx(), t, "ok_module.json", ns.ID, &types.ModuleConfig{
DAL: types.ModuleConfigDAL{
ConnectionID: connection.ID,
},
})
h.apiInit().
Post(fmt.Sprintf("/compose/namespace/%d/module/%d/record/", ns.ID, module.ID)).
Body(loadRequestFromGenerics(t, "ok_record.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
}

View File

@@ -0,0 +1,129 @@
package dal
import (
"encoding/json"
"fmt"
"net/http"
"testing"
"github.com/cortezaproject/corteza/server/tests/helpers"
jsonpath "github.com/steinfletcher/apitest-jsonpath"
)
func Test_dal_crud_issues_connection_connectivity(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeDalConnectionCRUD(h)
aux := &dalConnectionRestRsp{}
rsp := h.apiInit().
Post("/system/dal/connections/").
Body(loadRequestFromGenerics(t, "nok_connection_connectivity.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.connectionID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
h.apiInit().
Put(fmt.Sprintf("/system/dal/connections/%d", aux.Response.ID)).
Body(loadRequestFromGenerics(t, "ok_connection.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.connectionID")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
h.apiInit().
Put(fmt.Sprintf("/system/dal/connections/%d", aux.Response.ID)).
Body(loadRequestFromGenerics(t, "nok_connection_connectivity.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.connectionID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
h.apiInit().
Delete(fmt.Sprintf("/system/dal/connections/%d", aux.Response.ID)).
Header("Accept", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.success.message")).
End()
}
func Test_dal_crud_issues_connection_sensitivity(t *testing.T) {
t.Skip("needs refactoring")
h := newHelperT(t)
defer h.cleanupDal()
helpers.AllowMeDalConnectionCRUD(h)
aux := &dalConnectionRestRsp{}
rsp := h.apiInit().
Post("/system/dal/connections/").
Body(loadRequestFromGenerics(t, "nok_connection_sensitivity.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.connectionID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
dd := json.NewDecoder(rsp.Response.Body)
h.a.NoError(dd.Decode(&aux))
h.apiInit().
Put(fmt.Sprintf("/system/dal/connections/%d", aux.Response.ID)).
Body(loadRequestFromGenerics(t, "ok_connection.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.connectionID")).
Assert(jsonpath.NotPresent("$.response.issues")).
End()
h.apiInit().
Put(fmt.Sprintf("/system/dal/connections/%d", aux.Response.ID)).
Body(loadRequestFromGenerics(t, "nok_connection_sensitivity.json")).
Header("Accept", "application/json").
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.response.connectionID")).
Assert(jsonpath.Len("$.response.issues", 1)).
End()
h.apiInit().
Delete(fmt.Sprintf("/system/dal/connections/%d", aux.Response.ID)).
Header("Accept", "application/json").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
Assert(jsonpath.Present("$.success.message")).
End()
}

View File

@@ -0,0 +1,359 @@
package dal
import (
"context"
"fmt"
"os"
"testing"
composeService "github.com/cortezaproject/corteza/server/compose/service"
composeTypes "github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/pkg/auth"
"github.com/cortezaproject/corteza/server/pkg/dal"
"github.com/cortezaproject/corteza/server/pkg/id"
"github.com/cortezaproject/corteza/server/store"
"github.com/cortezaproject/corteza/server/system/service"
"github.com/cortezaproject/corteza/server/system/types"
"github.com/cortezaproject/corteza/server/tests/dal/setup/mysql"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)
type (
driver struct {
name string
dsn string
setup func(ctx context.Context, t wrapTest, dsn string)
}
dalConnectionRestRsp struct {
Response *types.DalConnection
}
composeModuleRestRsp struct {
Response *composeTypes.Module
}
composeRecordRestRsp struct {
Response *composeTypes.Record
}
composeRecordSearchRestRsp struct {
Response struct {
Set composeTypes.RecordSet
}
}
wrapTest interface {
require.TestingT
Name() string
}
modelMetaMaker func(ident string) *dal.Model
attributeMaker func() dal.AttributeSet
)
const (
sysID = "ID"
sysNamespaceID = "namespaceID"
sysModuleID = "moduleID"
sysCreatedAt = "createdAt"
sysCreatedBy = "createdBy"
sysUpdatedAt = "updatedAt"
sysUpdatedBy = "updatedBy"
sysDeletedAt = "deletedAt"
sysDeletedBy = "deletedBy"
sysOwnedBy = "ownedBy"
colSysID = "id"
colSysNamespaceID = "rel_namespace"
colSysModuleID = "rel_module"
colSysCreatedAt = "created_at"
colSysCreatedBy = "created_by"
colSysUpdatedAt = "updated_at"
colSysUpdatedBy = "updated_by"
colSysDeletedAt = "deleted_at"
colSysDeletedBy = "deleted_by"
colSysOwnedBy = "owned_by"
)
func (h helper) cleanupDal() {
ds := service.DefaultStore
ctx := context.Background()
dd := dal.Service()
models, err := dd.SearchModels(ctx)
h.a.NoError(err)
for _, model := range models {
dd.Truncate(ctx, model.ToFilter(), nil)
}
h.a.NoError(store.TruncateComposeModuleFields(ctx, ds))
h.a.NoError(store.TruncateComposeModules(ctx, ds))
h.a.NoError(store.TruncateComposeNamespaces(ctx, ds))
h.a.NoError(store.TruncateDalSensitivityLevels(ctx, ds))
cc, _, err := store.SearchDalConnections(ctx, ds, types.DalConnectionFilter{})
h.a.NoError(err)
for _, c := range cc {
if c.Type == types.DalPrimaryConnectionResourceType {
continue
}
h.a.NoError(store.DeleteDalConnectionByID(ctx, ds, c.ID))
}
dd.Purge(ctx)
h.a.NoError(service.DefaultDalConnection.ReloadConnections(ctx))
h.a.NoError(composeService.DefaultModule.ReloadDALModels(ctx))
}
func initSvc(ctx context.Context, d driver) (dal.FullService, error) {
c := makeConnectionDefinition(d.dsn)
cm := dal.ConnectionConfig{
ModelIdent: c.Config.DAL.ModelIdent,
SensitivityLevelID: c.Config.Privacy.SensitivityLevelID,
Label: c.Handle,
}
svc, err := dal.New(zap.NewNop(), false)
if err != nil {
return nil, err
}
err = svc.ReplaceConnection(
ctx,
dal.MakeConnection(
c.ID,
nil,
dal.ConnectionParams{
Type: "corteza::dal:connection:dsn",
Params: map[string]any{
"dsn": d.dsn,
},
},
cm,
),
true,
)
if err != nil {
return nil, err
}
return svc, err
}
func setup(t *testing.T) (ctx context.Context, h helper, log *zap.Logger) {
log = zap.NewNop()
h = newHelperT(t)
u := &types.User{
ID: id.Next(),
}
u.SetRoles(auth.BypassRoles().IDs()...)
ctx = auth.SetIdentityToContext(context.Background(), u)
return ctx, h, log
}
func setupBench(b *testing.B) (ctx context.Context, h helper, log *zap.Logger) {
log = zap.NewNop()
h = newHelperB(b)
u := &types.User{
ID: id.Next(),
}
u.SetRoles(auth.BypassRoles().IDs()...)
ctx = auth.SetIdentityToContext(context.Background(), u)
return ctx, h, log
}
func bootstrap(rootTest *testing.T, run func(context.Context, *testing.T, helper, dal.FullService)) {
var (
ctx, h, log = setup(rootTest)
drivers = collectDrivers()
)
_ = log
for _, driver := range drivers {
rootTest.Run(driver.name, func(t *testing.T) {
if driver.dsn == "" {
t.Skip("DSN for DAL test not set")
}
svc, err := initSvc(ctx, driver)
require.NoError(t, err)
driver.setup(ctx, rootTest, driver.dsn)
run(ctx, t, h, svc)
})
}
}
func bootstrapWithModel(rootTest *testing.T, ident string, run func(context.Context, *testing.T, helper, dal.FullService, *dal.Model)) {
var (
ctx, h, log = setup(rootTest)
drivers = collectDrivers()
)
_ = log
for _, driver := range drivers {
rootTest.Run(driver.name, func(t *testing.T) {
if driver.dsn == "" {
t.Skip("DSN for DAL test not set")
}
svc, err := initSvc(ctx, driver)
require.NoError(t, err)
model := buildModel(ident, basicModelMeta, fullPartitionedSysAttributes)
driver.setup(ctx, rootTest, driver.dsn)
_, err = svc.ReplaceModel(ctx, nil, model)
require.NoError(t, err)
run(ctx, t, h, svc, model)
})
}
}
func bootstrapBenchmark(rootTest *testing.B, run func(context.Context, *testing.B, helper, dal.FullService)) {
var (
ctx, h, log = setupBench(rootTest)
drivers = collectDrivers()
)
_ = log
for _, driver := range drivers {
rootTest.Run(driver.name, func(b *testing.B) {
if driver.dsn == "" {
b.Skip("DSN for DAL test not set")
}
svc, err := initSvc(ctx, driver)
require.NoError(b, err)
driver.setup(ctx, rootTest, driver.dsn)
run(ctx, b, h, svc)
})
}
}
func collectDrivers() []driver {
return []driver{
// {
// name: "sqlite",
// dsn: "sqlite3+debug://file::memory:?cache=shared&mode=memory",
// setup: func(ctx context.Context, t *testing.T, dsn string) {
// conn, err := mysql.Setup(ctx, dsn)
// require.NoError(t, err)
// _, err = conn.Exec(loadSetupSource(t, "sqlite.sql"))
// require.NoError(t, err)
// },
// },
{
name: "mysql",
dsn: os.Getenv("DAL_TEST_DSN_MYSQL"),
setup: func(ctx context.Context, t wrapTest, dsn string) {
conn, err := mysql.Setup(ctx, dsn)
require.NoError(t, err)
_, err = conn.Exec(loadScenarioSources(t, "mysql", "sql"))
require.NoError(t, err)
},
},
// {
// name: "postgres",
// dsn: os.Getenv("DAL_TEST_DSN_POSTGRES"),
// setup: func(ctx context.Context, t *testing.T, dsn string) {
// conn, err := mysql.Setup(ctx, dsn)
// require.NoError(t, err)
// _, err = conn.Exec(loadSetupSource(t, "postgres.sql"))
// require.NoError(t, err)
// },
// },
}
}
func buildModel(ident string, mm modelMetaMaker, am attributeMaker, aa ...*dal.Attribute) *dal.Model {
out := mm(ident)
out.Attributes = aa
out.Attributes = append(out.Attributes, am()...)
return out
}
func basicModelMeta(ident string) *dal.Model {
return &dal.Model{
ConnectionID: 0,
Ident: ident,
Resource: fmt.Sprintf("testing-resource/%s", ident),
ResourceID: 0,
}
}
func fullSysAttributes() dal.AttributeSet {
return dal.AttributeSet{
dal.PrimaryAttribute(sysID, &dal.CodecAlias{Ident: colSysID}),
dal.FullAttribute(sysModuleID, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysModuleID}),
dal.FullAttribute(sysNamespaceID, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysNamespaceID}),
dal.FullAttribute(sysOwnedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysOwnedBy}),
dal.FullAttribute(sysCreatedAt, &dal.TypeTimestamp{}, &dal.CodecAlias{Ident: colSysCreatedAt}),
dal.FullAttribute(sysCreatedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysCreatedBy}),
dal.FullAttribute(sysUpdatedAt, &dal.TypeTimestamp{}, &dal.CodecAlias{Ident: colSysUpdatedAt}),
dal.FullAttribute(sysUpdatedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysUpdatedBy}),
dal.FullAttribute(sysDeletedAt, &dal.TypeTimestamp{}, &dal.CodecAlias{Ident: colSysDeletedAt}),
dal.FullAttribute(sysDeletedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysDeletedBy}),
}
}
func fullPartitionedSysAttributes() dal.AttributeSet {
return dal.AttributeSet{
dal.PrimaryAttribute(sysID, &dal.CodecAlias{Ident: colSysID}),
// mod and ns omitted here
dal.FullAttribute(sysOwnedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysOwnedBy}),
dal.FullAttribute(sysCreatedAt, &dal.TypeTimestamp{}, &dal.CodecAlias{Ident: colSysCreatedAt}),
dal.FullAttribute(sysCreatedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysCreatedBy}),
dal.FullAttribute(sysUpdatedAt, &dal.TypeTimestamp{}, &dal.CodecAlias{Ident: colSysUpdatedAt}),
dal.FullAttribute(sysUpdatedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysUpdatedBy}),
dal.FullAttribute(sysDeletedAt, &dal.TypeTimestamp{}, &dal.CodecAlias{Ident: colSysDeletedAt}),
dal.FullAttribute(sysDeletedBy, &dal.TypeID{}, &dal.CodecAlias{Ident: colSysDeletedBy}),
}
}
func drain(ctx context.Context, i dal.Iterator) (rr []*composeTypes.Record, err error) {
var r *composeTypes.Record
rr = make([]*composeTypes.Record, 0, 100)
for i.Next(ctx) {
if i.Err() != nil {
return nil, i.Err()
}
r = new(composeTypes.Record)
if err = i.Scan(r); err != nil {
return
}
rr = append(rr, r)
}
return rr, i.Err()
}

View File

@@ -0,0 +1,451 @@
package dal
import (
"bufio"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path"
"testing"
"time"
"github.com/cortezaproject/corteza/server/pkg/auth"
"github.com/cortezaproject/corteza/server/pkg/id"
"github.com/cortezaproject/corteza/server/pkg/rbac"
"github.com/cortezaproject/corteza/server/store"
"github.com/steinfletcher/apitest"
"github.com/cortezaproject/corteza/server/app"
"github.com/cortezaproject/corteza/server/auth/handlers"
"github.com/cortezaproject/corteza/server/auth/request"
composeRest "github.com/cortezaproject/corteza/server/compose/rest"
composeService "github.com/cortezaproject/corteza/server/compose/service"
composeTypes "github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/pkg/api/server"
"github.com/cortezaproject/corteza/server/pkg/cli"
"github.com/cortezaproject/corteza/server/pkg/locale"
"github.com/cortezaproject/corteza/server/pkg/logger"
"github.com/cortezaproject/corteza/server/pkg/objstore/plain"
"github.com/cortezaproject/corteza/server/pkg/rand"
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/sqlite"
"github.com/cortezaproject/corteza/server/system/rest"
"github.com/cortezaproject/corteza/server/system/service"
"github.com/cortezaproject/corteza/server/system/types"
"github.com/cortezaproject/corteza/server/tests/helpers"
"github.com/go-chi/chi/v5"
_ "github.com/joho/godotenv/autoload"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"golang.org/x/text/language"
)
type (
helper struct {
t *testing.T
b *testing.B
a *require.Assertions
cUser *types.User
roleID uint64
token []byte
}
)
var (
testApp *app.CortezaApp
r chi.Router
testUser *types.User
hh *handlers.AuthHandlers
)
func init() {
helpers.RecursiveDotEnvLoad()
}
func TestMain(m *testing.M) {
InitTestApp()
os.Exit(m.Run())
}
func InitTestApp() {
var sm *request.SessionManager
if testApp == nil {
ctx := cli.Context()
testApp = helpers.NewIntegrationTestApp(ctx, func(app *app.CortezaApp) (err error) {
service.CurrentSettings.Auth.External.Enabled = true
service.DefaultObjectStore, err = plain.NewWithAfero(afero.NewMemMapFs(), "test")
if err != nil {
return err
}
service.DefaultStore, err = sqlite.ConnectInMemory(ctx)
if err != nil {
return err
}
// Tests should be executed w/o any locales
locale.SetGlobal(locale.Static(&locale.Language{Tag: language.Und}))
sm = request.NewSessionManager(service.DefaultStore, app.Opt.Auth, service.DefaultLogger)
return nil
})
if err := store.TruncateUsers(context.Background(), service.DefaultStore); err != nil {
panic(fmt.Errorf("could not cleanup users: %v", err))
}
if err := testApp.Activate(ctx); err != nil {
panic(fmt.Errorf("could not activate corteza: %v", err))
}
}
hh = &handlers.AuthHandlers{
Log: zap.NewNop(),
AuthService: service.DefaultAuth,
SessionManager: sm,
}
if r == nil {
r = chi.NewRouter()
r.Use(server.BaseMiddleware(false, logger.Default())...)
helpers.BindAuthMiddleware(r)
r.Route("/system", func(r chi.Router) {
r.Group(rest.MountRoutes())
})
r.Route("/compose", func(r chi.Router) {
r.Group(composeRest.MountRoutes())
})
hh.MountHttpRoutes(r)
}
}
func newHelperT(t *testing.T) helper {
h := newHelper(t, require.New(t))
h.t = t
return h
}
func newHelperB(b *testing.B) helper {
h := newHelper(b, require.New(b))
h.b = b
return h
}
func newHelper(_ require.TestingT, a *require.Assertions) helper {
var (
h = helper{
a: a,
roleID: id.Next(),
}
ctx = context.Background()
)
if testUser == nil {
testUser = &types.User{
Handle: "test_user",
Name: "test_user",
ID: id.Next(),
CreatedAt: time.Now(),
}
err := store.CreateUser(ctx, service.DefaultStore, testUser)
if err != nil {
panic(err)
}
}
h.cUser = testUser
h.cUser.SetRoles(h.roleID)
helpers.UpdateRBAC(h.roleID)
h.identityToHelper(ctx, h.cUser)
h.mockPermissionsWithAccess()
return h
}
// apiInit basics, initialize, set handler, add auth
func (h helper) apiInit() *apitest.APITest {
InitTestApp()
return apitest.
New().
Handler(r).
Intercept(helpers.ReqHeaderRawAuthBearer(h.token))
}
func (h helper) MyRole() uint64 {
return h.roleID
}
// Returns context w/ security details
func (h helper) secCtx() context.Context {
return auth.SetIdentityToContext(context.Background(), h.cUser)
}
func (h *helper) identityToHelper(ctx context.Context, u *types.User) {
var err error
h.cUser = u
h.token, err = auth.TokenIssuer.Issue(ctx, auth.WithIdentity(h.cUser))
if err != nil {
panic(err)
}
}
func (h helper) mockPermissions(rules ...*rbac.Rule) {
h.a.NoError(rbac.Global().Grant(
// TestService we use does not have any backend storage,
context.Background(),
rules...,
))
}
// Prepends allow access rule for system service for everyone
func (h helper) mockPermissionsWithAccess(rules ...*rbac.Rule) {
h.mockPermissions(rules...)
}
// // // // // // // // // // // // // // // // // // // // // // // // //
// Resource utilities
func (h helper) createNamespace(name string) *composeTypes.Namespace {
ns := &composeTypes.Namespace{Name: name, Slug: name}
ns.ID = id.Next()
ns.CreatedAt = time.Now()
h.a.NoError(store.CreateComposeNamespace(context.Background(), service.DefaultStore, ns))
return ns
}
func (h helper) createSensitivityLevel(res *types.DalSensitivityLevel) *types.DalSensitivityLevel {
if res.ID == 0 {
res.ID = id.Next()
}
if res.CreatedAt.IsZero() {
res.CreatedAt = time.Now()
}
h.a.NoError(service.DefaultStore.CreateDalSensitivityLevel(context.Background(), res))
h.a.NoError(service.DefaultDalSensitivityLevel.ReloadSensitivityLevels(context.Background(), service.DefaultStore))
return res
}
func (h helper) createDalConnection(res *types.DalConnection) *types.DalConnection {
if res.ID == 0 {
res.ID = id.Next()
}
if res.Meta.Name == "" {
res.Meta.Name = "Test Connection"
}
if res.Handle == "" {
res.Handle = "test_connection"
}
if res.Type == "" {
res.Type = types.DalConnectionResourceType
}
if res.Meta.Ownership == "" {
res.Meta.Ownership = "tester"
}
if res.Config.DAL == nil {
res.Config.DAL = &types.ConnectionConfigDAL{
Type: "corteza::dal:connection:dsn",
Params: map[string]any{
"dsn": "sqlite3://file::memory:?cache=shared&mode=memory",
},
}
}
if res.Config.DAL.ModelIdent == "" {
res.Config.DAL.ModelIdent = "compose_records"
}
if res.CreatedAt.IsZero() {
res.CreatedAt = time.Now()
}
if res.CreatedBy == 0 {
res.CreatedBy = h.cUser.ID
}
h.a.NoError(service.DefaultStore.CreateDalConnection(context.Background(), res))
h.a.NoError(service.DefaultDalConnection.ReloadConnections(context.Background()))
return res
}
func (h helper) getPrimaryConnection() *types.DalConnection {
cc, _, err := store.SearchDalConnections(context.Background(), service.DefaultStore, types.DalConnectionFilter{Type: types.DalPrimaryConnectionResourceType})
h.a.NoError(err)
if len(cc) != 1 {
h.a.FailNow("invalid state: no or too many primary connections")
}
return cc[0]
}
func makeConnectionDefinition(dsn string) *types.DalConnection {
return &types.DalConnection{
ID: id.Next(),
Type: types.DalConnectionResourceType,
Config: types.ConnectionConfig{
DAL: &types.ConnectionConfigDAL{
ModelIdent: "compose_record",
},
},
}
}
// // // // // // // // // // // // // // // // // // // // // // // // //
// Utilities
// ---
func loadRequestFromScenario(t *testing.T, name string) string {
return loadRequestFrom(t, suiteFromT(t), name)
}
func loadRequestFromGenerics(t *testing.T, name string) string {
return loadRequestFrom(t, "generic", name)
}
func loadRequestFrom(t *testing.T, suite, name string) string {
f, err := os.Open(path.Join("testdata", suite, name))
require.NoError(t, err)
defer f.Close()
bb, err := ioutil.ReadAll(f)
require.NoError(t, err)
return string(bb)
}
func loadRequestFromScenarioWithConnection(t *testing.T, req string, connectionID uint64) string {
out := loadRequestFromScenario(t, req)
aux := &composeTypes.Module{}
require.NoError(t, json.Unmarshal([]byte(out), &aux))
aux.Config.DAL.ConnectionID = connectionID
a, err := json.Marshal(aux)
require.NoError(t, err)
return string(a)
}
func createRecordFromCase(ctx context.Context, t *testing.T, name string, namespaceID, moduleID uint64) (record *composeTypes.Record) {
return createRecordFrom(ctx, t, suiteFromT(t), name, namespaceID, moduleID)
}
func createRecordFromGenerics(ctx context.Context, t *testing.T, name string, namespaceID, moduleID uint64) (record *composeTypes.Record) {
return createRecordFrom(ctx, t, "generic", name, namespaceID, moduleID)
}
func createRecordFrom(ctx context.Context, t *testing.T, suite, name string, namespaceID, moduleID uint64) (record *composeTypes.Record) {
raw := loadRequestFrom(t, suite, name)
record = &composeTypes.Record{}
require.NoError(t, json.Unmarshal([]byte(raw), &record))
record.NamespaceID = namespaceID
record.ModuleID = moduleID
record, _, err := composeService.DefaultRecord.Create(ctx, record)
require.NoError(t, err)
return record
}
func createModuleFromCase(ctx context.Context, t *testing.T, name string, namespaceID uint64, config *composeTypes.ModuleConfig) (module *composeTypes.Module) {
return createModuleFrom(ctx, t, suiteFromT(t), name, namespaceID, config)
}
func createModuleFromGenerics(ctx context.Context, t *testing.T, name string, namespaceID uint64, config *composeTypes.ModuleConfig) (module *composeTypes.Module) {
return createModuleFrom(ctx, t, "generic", name, namespaceID, config)
}
func createModuleFrom(ctx context.Context, t *testing.T, suite, name string, namespaceID uint64, config *composeTypes.ModuleConfig) (module *composeTypes.Module) {
raw := loadRequestFrom(t, suite, name)
module = &composeTypes.Module{}
require.NoError(t, json.Unmarshal([]byte(raw), &module))
module.NamespaceID = namespaceID
if config != nil {
// let's be careful not to override whole config
module.Config.DAL = config.DAL
}
module, err := composeService.DefaultModule.Create(ctx, module)
require.NoError(t, err)
return module
}
func createConnectionFromCase(ctx context.Context, t *testing.T, name string) (connection *types.DalConnection) {
return createConnectionFrom(ctx, t, suiteFromT(t), name)
}
func createConnectionFromGenerics(ctx context.Context, t *testing.T, name string) (connection *types.DalConnection) {
return createConnectionFrom(ctx, t, "generic", name)
}
func createConnectionFrom(ctx context.Context, t *testing.T, suite, name string) (connection *types.DalConnection) {
raw := loadRequestFrom(t, suite, name)
aux := &types.DalConnection{}
require.NoError(t, json.Unmarshal([]byte(raw), &aux))
connection, err := service.DefaultDalConnection.Create(ctx, aux)
require.NoError(t, err)
return connection
}
// ---
func suiteFromT(t *testing.T) string {
return t.Name()[5:]
}
// random string, 10 chars long by default
func rs(a ...int) string {
var l = 10
if len(a) > 0 {
l = a[0]
}
return string(rand.Bytes(l))
}
func loadScenarioSources(t wrapTest, driver, ext string) (src string) {
scenarioName := t.Name()[5:]
src = loadScenarioSource(t, "generic", fmt.Sprintf("_.%s", ext))
src += "\n"
src += loadScenarioSource(t, "generic", fmt.Sprintf("%s.%s", driver, ext))
src += "\n"
src += loadScenarioSource(t, scenarioName, fmt.Sprintf("_.%s", ext))
src += "\n"
src += loadScenarioSource(t, scenarioName, fmt.Sprintf("%s.%s", driver, ext))
return
}
func loadScenarioSource(t wrapTest, scenarioName, srcName string) (src string) {
f, err := os.Open(path.Join("testdata", scenarioName, srcName))
if err != nil && os.IsNotExist(err) {
return ""
}
require.NoError(t, err)
defer f.Close()
out, err := ioutil.ReadAll(bufio.NewReader(f))
require.NoError(t, err)
return string(out)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
package mysql
import (
"context"
"github.com/cortezaproject/corteza/server/pkg/logger"
"github.com/cortezaproject/corteza/server/store/adapters/rdbms"
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/mysql"
"github.com/jmoiron/sqlx"
)
func Setup(ctx context.Context, dsn string) (_ *sqlx.DB, err error) {
var (
cfg *rdbms.ConnConfig
)
cfg, err = mysql.NewConfig(dsn)
if err != nil {
return
}
return rdbms.Connect(ctx, logger.MakeDebugLogger(), cfg)
}

View File

@@ -0,0 +1,23 @@
package postgres
import (
"context"
"github.com/cortezaproject/corteza/server/pkg/logger"
"github.com/cortezaproject/corteza/server/store/adapters/rdbms"
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/postgres"
"github.com/jmoiron/sqlx"
)
func Setup(ctx context.Context, dsn string) (_ *sqlx.DB, err error) {
var (
cfg *rdbms.ConnConfig
)
cfg, err = postgres.NewConfig(dsn)
if err != nil {
return
}
return rdbms.Connect(ctx, logger.MakeDebugLogger(), cfg)
}

View File

@@ -0,0 +1,23 @@
package sqlite
import (
"context"
"github.com/cortezaproject/corteza/server/pkg/logger"
"github.com/cortezaproject/corteza/server/store/adapters/rdbms"
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/sqlite"
"github.com/jmoiron/sqlx"
)
func Setup(ctx context.Context, dsn string) (_ *sqlx.DB, err error) {
var (
cfg *rdbms.ConnConfig
)
cfg, err = sqlite.NewConfig(dsn)
if err != nil {
return
}
return rdbms.Connect(ctx, logger.MakeDebugLogger(), cfg)
}

View File

@@ -0,0 +1,48 @@
{
"handle": "primary_connection",
"type": "corteza::system:primary-dal-connection",
"meta": {
"name": "Primary Connection EDITED",
"location": {
"geometry": {
"type": "",
"coordinates": null
},
"properties": {
"name": ""
}
},
"ownership": ""
},
"config": {
"connection": {
"type": "corteza::dal:connection:dsn",
"params": {
"dsn": "sqlite3://file::memory:?cache=shared&mode=memory"
}
},
"privacy": {
"sensitivityLevelID": "0"
},
"dal": {
"properties": {},
"operations": [
"corteza::dal:operation:create",
"corteza::dal:operation:update",
"corteza::dal:operation:search",
"corteza::dal:operation:lookup",
"corteza::dal:operation:paging",
"corteza::dal:operation:stats",
"corteza::dal:operation:sorting",
"corteza::dal:operation:RBAC"
],
"modelIdent": "compose_record",
"attributeIdent": "values",
"partitionFormat": "compose_record_{{namespace}}_{{module}}",
"partitionIdentValidator": ""
}
}
}

View File

@@ -0,0 +1,34 @@
{
"name": "internal_non_partitioned",
"handle": "internal_non_partitioned",
"config": {
"dal": {
"connectionID": "42",
"operations": [],
"partitioned": false
},
"privacy": {
"sensitivityLevelID": "0",
"usageDisclosure": "A"
}
},
"fields": [
{
"name": "f1",
"kind": "String",
"privacy": {
"sensitivityLevelID": "0",
"usageDisclosure": "A"
}
},
{
"name": "f2",
"kind": "String"
}
]
}

48
server/tests/dal/testdata/generic/_.sql vendored Normal file
View File

@@ -0,0 +1,48 @@
DROP TABLE IF EXISTS compose_record;
CREATE TABLE `compose_record` (
`id` bigint unsigned NOT NULL,
`rel_namespace` bigint unsigned NOT NULL,
`module_id` bigint unsigned NOT NULL,
`values` json DEFAULT NULL,
`owned_by` bigint unsigned NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`created_by` bigint unsigned NOT NULL,
`updated_by` bigint unsigned NOT NULL DEFAULT '0',
`deleted_by` bigint unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `compose_record_owner` (`owned_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
DROP TABLE IF EXISTS compose_record_partitioned;
CREATE TABLE `compose_record_partitioned` (
`id` bigint unsigned NOT NULL,
`vID` BIGINT UNSIGNED,
`vRef` BIGINT UNSIGNED,
`vTimestamp` DATETIME,
`vTime` TIME,
`vDate` DATE,
`vNumber` NUMERIC,
`vText` TEXT,
`vBoolean_T` BOOLEAN,
`vBoolean_F` BOOLEAN,
`vEnum` TEXT,
`vGeometry` TEXT,
`vJSON` TEXT,
`vBlob` BLOB,
`vUUID` VARCHAR(36),
`owned_by` bigint unsigned NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`created_by` bigint unsigned NOT NULL,
`updated_by` bigint unsigned NOT NULL DEFAULT '0',
`deleted_by` bigint unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `compose_record_owner` (`owned_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

View File

@@ -0,0 +1,32 @@
{
"handle": "test_connection",
"type": "corteza::system:dal-connection",
"meta": {
"name": "Test Connection",
"location": {
"geometry": {
"type": "",
"coordinates": null
},
"properties": {
"name": ""
}
},
"ownership": ""
},
"config": {
"dal": {
"modelIdent": "compose_record",
"type": "corteza::dal:connection:dsn",
"params": {
"dsn": "NO"
}
},
"privacy": {
"sensitivityLevelID": "0"
}
}
}

View File

@@ -0,0 +1,32 @@
{
"handle": "test_connection",
"type": "corteza::system:primary-dal-connection",
"meta": {
"name": "Test Connection",
"location": {
"geometry": {
"type": "",
"coordinates": null
},
"properties": {
"name": ""
}
},
"ownership": ""
},
"config": {
"dal": {
"modelIdent": "compose_record",
"type": "corteza::dal:connection:dsn",
"params": {
"dsn": "sqlite3://file::memory:?cache=shared&mode=memory"
}
},
"privacy": {
"sensitivityLevelID": "0"
}
}
}

View File

@@ -0,0 +1,32 @@
{
"handle": "test_connection",
"type": "corteza::system:dal-connection",
"meta": {
"name": "Test Connection",
"location": {
"geometry": {
"type": "",
"coordinates": null
},
"properties": {
"name": ""
}
},
"ownership": ""
},
"config": {
"dal": {
"modelIdent": "compose_record",
"type": "corteza::dal:connection:dsn",
"params": {
"dsn": "sqlite3://file::memory:?cache=shared&mode=memory"
}
},
"privacy": {
"sensitivityLevelID": "42"
}
}
}

View File

@@ -0,0 +1,38 @@
{
"name": "internal_non_partitioned",
"handle": "internal_non_partitioned",
"config": {
"dal": {
"connectionID": "0",
"operations": [],
"partitioned": false
},
"privacy": {
"sensitivityLevelID": "0",
"usageDisclosure": "A"
}
},
"fields": [
{
"name": "name",
"kind": "String",
"config": {
"privacy": {
"sensitivityLevelID": "42",
"usageDisclosure": "A"
}
}
},
{
"name": "email",
"kind": "Email"
},
{
"name": "a_number",
"kind": "Number"
}
]
}

View File

@@ -0,0 +1,36 @@
{
"name": "internal_non_partitioned",
"handle": "internal_non_partitioned",
"config": {
"dal": {
"connectionID": "0",
"operations": [],
"partitioned": false
},
"privacy": {
"sensitivityLevelID": "42",
"usageDisclosure": "A"
}
},
"fields": [
{
"name": "name",
"kind": "String",
"privacy": {
"sensitivityLevelID": "0",
"usageDisclosure": "A"
}
},
{
"name": "email",
"kind": "Email"
},
{
"name": "a_number",
"kind": "Number"
}
]
}

View File

@@ -0,0 +1,37 @@
{
"name": "internal_non_partitioned",
"handle": "internal_non_partitioned",
"config": {
"dal": {
"connectionID": "0",
"operations": [],
"partitioned": false
},
"privacy": {
"sensitivityLevelID": "42",
"usageDisclosure": "A"
}
},
"fields": [
{
"name": "name",
"kind": "String",
"privacy": {
"sensitivityLevelID": "0",
"usageDisclosure": "A"
}
},
{
"name": "email",
"kind": "Email"
},
{
"name": "a_number",
"kind": "Number"
}
]
}

View File

@@ -0,0 +1,32 @@
{
"handle": "test_connection",
"type": "corteza::system:dal-connection",
"meta": {
"name": "Test Connection",
"location": {
"geometry": {
"type": "",
"coordinates": null
},
"properties": {
"name": ""
}
},
"ownership": ""
},
"config": {
"dal": {
"modelIdent": "compose_record",
"type": "corteza::dal:connection:dsn",
"params": {
"dsn": "sqlite3://file::memory:?cache=shared&mode=memory"
}
},
"privacy": {
"sensitivityLevelID": "0"
}
}
}

View File

@@ -0,0 +1,32 @@
{
"handle": "test_connection_edited",
"type": "corteza::system:dal-connection",
"meta": {
"name": "Test Connection EDITED",
"location": {
"geometry": {
"type": "",
"coordinates": null
},
"properties": {
"name": ""
}
},
"ownership": ""
},
"config": {
"dal": {
"modelIdent": "compose_record",
"type": "corteza::dal:connection:dsn",
"params": {
"dsn": "sqlite3://file::memory:?cache=shared&mode=memory"
}
},
"privacy": {
"sensitivityLevelID": "0"
}
}
}

View File

@@ -0,0 +1,31 @@
{
"name": "internal_non_partitioned",
"handle": "internal_non_partitioned",
"config": {
"dal": {
"connectionID": "0",
"operations": [],
"partitioned": false
},
"privacy": {
"sensitivityLevelID": "0",
"usageDisclosure": "A"
}
},
"fields": [
{
"name": "name",
"kind": "String"
},
{
"name": "email",
"kind": "Email"
},
{
"name": "a_number",
"kind": "Number"
}
]
}

View File

@@ -0,0 +1,16 @@
{
"values": [
{
"name": "name",
"value": "Me"
},
{
"name": "email",
"value": "me@test.tld"
},
{
"name": "a_number",
"value": "42"
}
]
}

View File

@@ -0,0 +1,16 @@
{
"values": [
{
"name": "name",
"value": "Me updated"
},
{
"name": "email",
"value": "me+updated@test.tld"
},
{
"name": "a_number",
"value": "43"
}
]
}

View File

@@ -0,0 +1,8 @@
{
"handle": "private",
"level": 1,
"meta": {
"name": "private sensitivity",
"description": "data is private to the owner"
}
}

View File

@@ -0,0 +1,8 @@
{
"handle": "private_edited",
"level": 1,
"meta": {
"name": "private sensitivity",
"description": "data is private to the owner"
}
}