Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add calendar and contacts service #8357

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def testPipelines(ctx):
pipelines.append(wopiValidatorTests(ctx, "ocis", "default"))

pipelines += localApiTestPipeline(ctx)
pipelines += ccsTestPipeline(ctx)

if "skip" not in config["apiTests"] or not config["apiTests"]["skip"]:
pipelines += apiTests(ctx)
Expand Down Expand Up @@ -862,6 +863,68 @@ def localApiTests(suite, storage, extra_environment = {}):
],
}]

def ccsTestPipeline(ctx):
storage = "ocis"

pipeline = {
"kind": "pipeline",
"type": "docker",
"name": "calendar-contacts-tests",
"platform": {
"os": "linux",
"arch": "amd64",
},
"steps": restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin") +
ocisServer(storage, with_wrapper = False) +
ccsTests(storage),
"services": [],
"depends_on": getPipelineNames([buildOcisBinaryForTesting(ctx)]),
"trigger": {
"ref": [
"refs/heads/master",
"refs/pull/**",
],
},
}

pipelines = []
pipelines.append(pipeline)
return pipelines

def ccsTests(storage):
environment = {
"PATH_TO_OCIS": dirs["base"],
"TEST_SERVER_URL": "https://ocis-server:9200",
"OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""),
"OCIS_SKELETON_STRATEGY": "%s" % ("copy" if storage == "owncloud" else "upload"),
"SEND_SCENARIO_LINE_REFERENCES": "true",
"STORAGE_DRIVER": storage,
}

return [{
"name": "ccsTests",
"image": "deepdiver/ccs-caldavtester:latest",
"environment": environment,
"commands": [
"pwd",
"ping ocis-server -c1",
# create some calendars and addressbooks
"curl -X MKCOL https://ocis-server:9200/ccs/calendars/einstein/calendar -kv -ueinstein:relativity",
"curl -X MKCOL https://ocis-server:9200/ccs/addressbooks/einstein/addressbook -kv -ueinstein:relativity",
# run caldav tests
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CalDAV/well-known.xml",
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CalDAV/current-user-principal.xml",
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CalDAV/get.xml",
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CalDAV/caldavIOP.xml",
# run carddav tests
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CardDAV/well-known.xml",
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CardDAV/current-user-principal.xml",
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CardDAV/get.xml",
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CardDAV/propfind.xml",
"python3 /app/testcaldav.py --ssl --print-details-onfail --basedir tests/ccs CardDAV/mkcol.xml",
],
}]

def cs3ApiTests(ctx, storage, accounts_hash_difficulty = 4):
return {
"kind": "pipeline",
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ OCIS_MODULES = \
services/auth-bearer \
services/auth-machine \
services/auth-service \
services/ccs \
services/clientlog \
services/eventhistory \
services/frontend \
Expand Down
18 changes: 18 additions & 0 deletions docs/services/ccs/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: "Calendar and contacts service"
date: 2024-02-22T00:00:00+00:00
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/services/ccs
geekdocFilePath: _index.md
geekdocCollapseSection: true
---

## Abstract

This service provides CaldDAV and CardDAV


## Table of Contents

{{< toc-tree >}}
6 changes: 3 additions & 3 deletions docs/services/general-info/port-ranges.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ We also suggest to use the last port in your extensions' range as a debug/metric
| 9245-9249 | FREE |
| 9250-9254 | [ocis server (runtime)](https://github.com/owncloud/ocis/tree/master/ocis/pkg/runtime) |
| 9255-9259 | [postprocessing]({{< ref "../postprocessing/_index.md" >}}) |
| 9260-9264 | [clientlog]({{< ref "../clientlog/_index.md" >}}) |
| 9260-9264 | [clientlog]({{< ref "../clientlog/_index.md" >}}) |
| 9265-9269 | FREE |
| 9270-9274 | [eventhistory]({{< ref "../eventhistory/_index.md" >}}) |
| 9275-9279 | FREE |
| 9280-9284 | [ocm]({{< ref "../ocm/_index.md" >}}) |
| 9280-9284 | [ocm]({{< ref "../ocm/_index.md" >}}) |
| 9285-9289 | FREE |
| 9290-9294 | FREE |
| 9295-9299 | FREE |
Expand Down Expand Up @@ -209,5 +209,5 @@ We also suggest to use the last port in your extensions' range as a debug/metric
| 9975-9979 | FREE |
| 9980-9984 | FREE |
| 9985-9989 | FREE |
| 9990-9994 | FREE |
| 9990-9994 | [calendar and contacts service]({{< ref "../ccs/_index.md" >}}) |
| 9995-9999 | FREE |
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.0
require (
dario.cat/mergo v1.0.0
github.com/CiscoM31/godata v1.0.10
github.com/DeepDiver1975/go-webdav v0.0.0-20240308110728-8857da010229
github.com/KimMachineGun/automemlimit v0.5.0
github.com/Masterminds/semver v1.5.0
github.com/MicahParks/keyfunc v1.9.0
Expand All @@ -19,6 +20,8 @@ require (
github.com/disintegration/imaging v1.6.2
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
github.com/egirna/icap-client v0.1.1
github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f
github.com/emersion/go-vcard v0.0.0-20230815062825-8fda7d206ec9
github.com/gabriel-vasile/mimetype v1.4.3
github.com/ggwhite/go-masker v1.1.0
github.com/go-chi/chi/v5 v5.0.12
Expand Down Expand Up @@ -314,6 +317,7 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/studio-b12/gowebdav v0.0.0-20221015232716-17255f2e7423 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/teambition/rrule-go v1.8.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 // indirect
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/CiscoM31/godata v1.0.10 h1:DZdJ6M8QNh4HquvDDOqNLu6h77Wl86KGK7Qlbmb90sk=
github.com/CiscoM31/godata v1.0.10/go.mod h1:ZMiT6JuD3Rm83HEtiTx4JEChsd25YCrxchKGag/sdTc=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DeepDiver1975/go-webdav v0.0.0-20240308110728-8857da010229 h1:87YdHDobZHYm4tqpEX/GnidYmEupIJ02Zst/uEkFN40=
github.com/DeepDiver1975/go-webdav v0.0.0-20240308110728-8857da010229/go.mod h1:oTZKMN5qSdbmLQvbRJVcv0i2J/+w9aXQORFHNZi3XY4=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/KimMachineGun/automemlimit v0.5.0 h1:BeOe+BbJc8L5chL3OwzVYjVzyvPALdd5wxVVOWuUZmQ=
github.com/KimMachineGun/automemlimit v0.5.0/go.mod h1:di3GCKiu9Y+1fs92erCbUvKzPkNyViN3mA0vti/ykEQ=
Expand Down Expand Up @@ -1073,6 +1075,10 @@ github.com/egirna/icap v0.0.0-20181108071049-d5ee18bd70bc h1:6IxmRbXV8WXVkcYcTzk
github.com/egirna/icap v0.0.0-20181108071049-d5ee18bd70bc/go.mod h1:FdVN2WHg7zOHhJ7kZQdDorfFhIfqZaHttjAzDDvAXHE=
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f h1:feGUUxxvOtWVOhTko8Cbmp33a+tU0IMZxMEmnkoAISQ=
github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f/go.mod h1:2MKFUgfNMULRxqZkadG1Vh44we3y5gJAtTBlVsx1BKQ=
github.com/emersion/go-vcard v0.0.0-20230815062825-8fda7d206ec9 h1:ATgqloALX6cHCranzkLb8/zjivwQ9DWWDCQRnxTPfaA=
github.com/emersion/go-vcard v0.0.0-20230815062825-8fda7d206ec9/go.mod h1:HMJKR5wlh/ziNp+sHEDV2ltblO4JD2+IdDOWtGcQBTM=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/emvi/iso-639-1 v1.1.0 h1:EhZiYVA+ysa/b7+0T2DD9hcX7E/5sh4o1KyDAIPu7VE=
Expand Down Expand Up @@ -2019,6 +2025,9 @@ github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxm
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes=
github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
github.com/teambition/rrule-go v1.7.2/go.mod h1:mBJ1Ht5uboJ6jexKdNUJg2NcwP8uUMNvStWXlJD3MvU=
github.com/teambition/rrule-go v1.8.2 h1:lIjpjvWTj9fFUZCmuoVDrKVOtdiyzbzc93qTmRVe/J8=
github.com/teambition/rrule-go v1.8.2/go.mod h1:Ieq5AbrKGciP1V//Wq8ktsTXwSwJHDD5mD/wLBGl3p4=
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
github.com/thanhpk/randstr v1.0.6 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o=
Expand Down
2 changes: 2 additions & 0 deletions ocis-pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
authbearer "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config"
authmachine "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config"
authservice "github.com/owncloud/ocis/v2/services/auth-service/pkg/config"
ccs "github.com/owncloud/ocis/v2/services/ccs/pkg/config"
clientlog "github.com/owncloud/ocis/v2/services/clientlog/pkg/config"
eventhistory "github.com/owncloud/ocis/v2/services/eventhistory/pkg/config"
frontend "github.com/owncloud/ocis/v2/services/frontend/pkg/config"
Expand Down Expand Up @@ -87,6 +88,7 @@ type Config struct {
AuthBearer *authbearer.Config `yaml:"auth_bearer"`
AuthMachine *authmachine.Config `yaml:"auth_machine"`
AuthService *authservice.Config `yaml:"auth_service"`
CCS *ccs.Config `yaml:"ccs"`
Clientlog *clientlog.Config `yaml:"clientlog"`
EventHistory *eventhistory.Config `yaml:"eventhistory"`
Frontend *frontend.Config `yaml:"frontend"`
Expand Down
2 changes: 2 additions & 0 deletions ocis-pkg/config/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
authbearer "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config/defaults"
authmachine "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config/defaults"
authservice "github.com/owncloud/ocis/v2/services/auth-service/pkg/config/defaults"
ccs "github.com/owncloud/ocis/v2/services/ccs/pkg/config/defaults"
clientlog "github.com/owncloud/ocis/v2/services/clientlog/pkg/config/defaults"
eventhistory "github.com/owncloud/ocis/v2/services/eventhistory/pkg/config/defaults"
frontend "github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults"
Expand Down Expand Up @@ -59,6 +60,7 @@ func DefaultConfig() *Config {
AuthBearer: authbearer.DefaultConfig(),
AuthMachine: authmachine.DefaultConfig(),
AuthService: authservice.DefaultConfig(),
CCS: ccs.DefaultConfig(),
Clientlog: clientlog.DefaultConfig(),
EventHistory: eventhistory.DefaultConfig(),
Frontend: frontend.DefaultConfig(),
Expand Down
6 changes: 6 additions & 0 deletions ocis/pkg/command/services.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package command

import (
ccs "github.com/owncloud/ocis/v2/services/ccs/pkg/command"
"github.com/urfave/cli/v2"

"github.com/owncloud/ocis/v2/ocis-pkg/config"
Expand Down Expand Up @@ -91,6 +92,11 @@ var svccmds = []register.Command{
cfg.AuthService.Commons = cfg.Commons
})
},
func(cfg *config.Config) *cli.Command {
return ServiceCommand(cfg, cfg.CCS.Service.Name, ccs.GetCommands(cfg.CCS), func(c *config.Config) {
cfg.Clientlog.Commons = cfg.Commons
})
},
func(cfg *config.Config) *cli.Command {
return ServiceCommand(cfg, cfg.Clientlog.Service.Name, clientlog.GetCommands(cfg.Clientlog), func(c *config.Config) {
cfg.Clientlog.Commons = cfg.Commons
Expand Down
7 changes: 7 additions & 0 deletions ocis/pkg/runtime/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"context"
"fmt"
ccs "github.com/owncloud/ocis/v2/services/ccs/pkg/command"
"net"
"net/http"
"net/rpc"
Expand Down Expand Up @@ -299,6 +300,12 @@ func NewService(options ...Option) (*Service, error) {
cfg.OCM.Commons = cfg.Commons
return ocm.Execute(cfg.OCM)
})
// wait for system storage
reg(4, opts.Config.CCS.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error {
cfg.CCS.Context = ctx
cfg.CCS.Commons = cfg.Commons
return ccs.Execute(cfg.CCS)
})

// out of some unknown reason ci gets angry when frontend service starts in priority group 3
// this is not reproducible locally, it can start when nats and gateway are already running
Expand Down
37 changes: 37 additions & 0 deletions services/ccs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SHELL := bash
NAME := ccs

include ../../.make/recursion.mk

############ tooling ############
ifneq (, $(shell command -v go 2> /dev/null)) # suppress `command not found warnings` for non go targets in CI
include ../../.bingo/Variables.mk
endif

############ go tooling ############
include ../../.make/go.mk

############ release ############
include ../../.make/release.mk

############ docs generate ############
include ../../.make/docs.mk

.PHONY: docs-generate
docs-generate: config-docs-generate

############ generate ############
include ../../.make/generate.mk

.PHONY: ci-go-generate
ci-go-generate: # CI runs ci-node-generate automatically before this target

.PHONY: ci-node-generate
ci-node-generate:

############ licenses ############
.PHONY: ci-node-check-licenses
ci-node-check-licenses:

.PHONY: ci-node-save-licenses
ci-node-save-licenses:
2 changes: 2 additions & 0 deletions services/ccs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ccs

14 changes: 14 additions & 0 deletions services/ccs/cmd/ccs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"os"

"github.com/owncloud/ocis/v2/services/ccs/pkg/command"
"github.com/owncloud/ocis/v2/services/ccs/pkg/config/defaults"
)

func main() {
if err := command.Execute(defaults.DefaultConfig()); err != nil {
os.Exit(1)
}
}
79 changes: 79 additions & 0 deletions services/ccs/pkg/command/create_addressbook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package command

import (
"context"
"fmt"
"github.com/DeepDiver1975/go-webdav/carddav"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
revaContext "github.com/cs3org/reva/v2/pkg/ctx"
config2 "github.com/owncloud/ocis/v2/ocis-pkg/config"
parser2 "github.com/owncloud/ocis/v2/ocis-pkg/config/parser"
ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
"github.com/owncloud/ocis/v2/services/ccs/pkg/config"
"github.com/owncloud/ocis/v2/services/ccs/pkg/config/parser"
svc "github.com/owncloud/ocis/v2/services/ccs/pkg/service/v0"
"github.com/urfave/cli/v2"
)

func CreateAddressBook(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "create-addressbook",
Usage: "create addressbook for user",
Category: "maintenance",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "user-name",
Value: "string",
Usage: "user name",
Required: true,
},
&cli.StringFlag{
Name: "addressbook-name",
Value: "string",
Usage: "addressbook name",
Required: true,
},
},
Before: func(c *cli.Context) error {
// load ocis config if possible
ocisConfig := config2.Config{}
err := parser2.ParseConfig(&ocisConfig, false)
if err != nil {
return err
}
cfg.Commons = ocisConfig.Commons
err = parser.ParseConfig(cfg)
if err != nil {
return err
}

return nil
},
Action: func(c *cli.Context) error {
// init grpc connection
_, err := ogrpc.NewClient()
if err != nil {
return err
}

_, _, backend, err := svc.InitStorage(c.Context, cfg.Storage)
if err != nil {
return err
}
userName := c.String("user-name")
bookName := c.String("addressbook-name")
path := fmt.Sprintf("/dav/addressbooks/%s/%s", userName, bookName)

addressbook := carddav.AddressBook{
Path: path,
Name: bookName,
}
u := userpb.User{
Username: userName,
}
ctx := revaContext.ContextSetUser(context.Background(), &u)
err = backend.CreateAddressBook(ctx, &addressbook)
return err
},
}
}
Loading