-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[full-ci] enhancement: allow ocis to provide custom web applications (#…
…8523) * enhancement: allow ocis to provide custom web applications * enhancement: add an option to disable web apps * test: add default logger tests * test: add app loading tests * test: add asset server tests * enhancement: make use of dedicated app conf file and app asset paths * enhancement: adjust asset locations and deprecate WEB_ASSET_PATH * enhancement: get rid of default logger and use the service level logger instead * Apply suggestions from code review Co-authored-by: Benedikt Kulmann <benedikt@kulmann.biz> Co-authored-by: kobergj <juliankoberg@googlemail.com> * enhancement: use basename as app id * Apply suggestions from code review Co-authored-by: Martin <github@diemattels.at> * enhancement: use afero as fs abstraction * enhancement: simplify logo upload * enhancement: make use of introductionVersion field annotations --------- Co-authored-by: Benedikt Kulmann <benedikt@kulmann.biz> Co-authored-by: kobergj <juliankoberg@googlemail.com> Co-authored-by: Martin <github@diemattels.at>
- Loading branch information
1 parent
6ba9e4a
commit 6814c61
Showing
63 changed files
with
5,834 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Enhancement: Custom WEB App Loading | ||
|
||
We've added a new feature which allows the administrator of the environment to provide custom web applications to the | ||
users. This feature is useful for organizations that have specific web applications that they want to provide to their | ||
users. | ||
|
||
The users will then be able to access these custom web applications from the web ui. | ||
For a detailed description of the feature, please read the WEB service README.md file. | ||
|
||
https://github.com/owncloud/ocis/pull/8523 | ||
https://github.com/owncloud/ocis/issues/8392 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package testenv | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
// CMDTest spawns a new independent test environment | ||
type CMDTest struct { | ||
n string | ||
f func() | ||
} | ||
|
||
// NewCMDTest creates a new CMDTest instance | ||
func NewCMDTest(name string) CMDTest { | ||
return CMDTest{ | ||
n: name, | ||
} | ||
} | ||
|
||
// Run runs the cmd subtest | ||
func (t CMDTest) Run(envs ...string) ([]byte, error) { | ||
cmd := exec.Command(os.Args[0], fmt.Sprintf("-test.run=%s", t.n)) | ||
cmd.Env = append(os.Environ(), "RUN_CMD_TEST=1") | ||
cmd.Env = append(cmd.Env, envs...) | ||
|
||
return cmd.CombinedOutput() | ||
} | ||
|
||
// ShouldRun checks if the cmd subtest should run | ||
func (CMDTest) ShouldRun() bool { | ||
return os.Getenv("RUN_CMD_TEST") == "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package testenv | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/onsi/gomega" | ||
) | ||
|
||
func TestNewSubTest(t *testing.T) { | ||
testString := "this is a sub-test" | ||
cmdTest := NewCMDTest(t.Name()) | ||
if cmdTest.ShouldRun() { | ||
fmt.Println(testString) | ||
return | ||
} | ||
|
||
out, err := cmdTest.Run() | ||
|
||
g := gomega.NewWithT(t) | ||
g.Expect(err).ToNot(gomega.HaveOccurred()) | ||
g.Expect(string(out)).To(gomega.ContainSubstring(testString)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package log_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/onsi/gomega" | ||
|
||
"github.com/owncloud/ocis/v2/internal/testenv" | ||
"github.com/owncloud/ocis/v2/ocis-pkg/log" | ||
) | ||
|
||
func TestDeprecation(t *testing.T) { | ||
cmdTest := testenv.NewCMDTest(t.Name()) | ||
if cmdTest.ShouldRun() { | ||
log.Deprecation("this is a deprecation") | ||
return | ||
} | ||
|
||
out, err := cmdTest.Run() | ||
|
||
g := gomega.NewWithT(t) | ||
g.Expect(err).ToNot(gomega.HaveOccurred()) | ||
g.Expect(string(out)).To(gomega.HavePrefix("\033[1;31mDEPRECATION: this is a deprecation")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package fsx | ||
|
||
import ( | ||
"github.com/spf13/afero" | ||
) | ||
|
||
var ( | ||
// assert interfaces implemented | ||
_ afero.Fs = (*FallbackFS)(nil) | ||
_ FS = (*FallbackFS)(nil) | ||
) | ||
|
||
// FallbackFS is a filesystem that layers a primary filesystem on top of a secondary filesystem. | ||
type FallbackFS struct { | ||
FS | ||
primary *BaseFS | ||
secondary *BaseFS | ||
} | ||
|
||
// Primary returns the primary filesystem. | ||
func (d *FallbackFS) Primary() *BaseFS { | ||
return d.primary | ||
} | ||
|
||
// Secondary returns the secondary filesystem. | ||
func (d *FallbackFS) Secondary() *BaseFS { | ||
return d.secondary | ||
} | ||
|
||
// NewFallbackFS returns a new FallbackFS instance. | ||
func NewFallbackFS(primary, secondary FS) *FallbackFS { | ||
return &FallbackFS{ | ||
FS: FromAfero(afero.NewCopyOnWriteFs(secondary, primary)), | ||
primary: &BaseFS{Fs: primary}, | ||
secondary: &BaseFS{Fs: secondary}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package fsx_test | ||
|
||
import ( | ||
"io" | ||
"testing" | ||
|
||
"github.com/onsi/gomega" | ||
"github.com/spf13/afero" | ||
|
||
"github.com/owncloud/ocis/v2/ocis-pkg/x/io/fsx" | ||
) | ||
|
||
func TestLayeredFS(t *testing.T) { | ||
g := gomega.NewWithT(t) | ||
|
||
read := func(fs fsx.FS, name string) (string, error) { | ||
f, err := fs.Open(name) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
b, err := io.ReadAll(f) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return string(b), nil | ||
} | ||
|
||
mustRead := func(fs fsx.FS, name string) string { | ||
s, err := read(fs, name) | ||
g.Expect(err).ToNot(gomega.HaveOccurred()) | ||
|
||
return s | ||
} | ||
|
||
create := func(fs fsx.FS, name, content string) { | ||
err := afero.WriteFile(fs, name, []byte(content), 0644) | ||
g.Expect(err).ToNot(gomega.HaveOccurred()) | ||
} | ||
|
||
primary := fsx.NewMemMapFs() | ||
create(primary, "both.txt", "primary") | ||
g.Expect(mustRead(primary, "both.txt")).To(gomega.Equal("primary")) | ||
create(primary, "primary.txt", "primary") | ||
g.Expect(mustRead(primary, "primary.txt")).To(gomega.Equal("primary")) | ||
|
||
secondary := fsx.NewMemMapFs() | ||
create(secondary, "both.txt", "secondary") | ||
g.Expect(mustRead(secondary, "both.txt")).To(gomega.Equal("secondary")) | ||
create(secondary, "secondary.txt", "secondary") | ||
g.Expect(mustRead(secondary, "secondary.txt")).To(gomega.Equal("secondary")) | ||
|
||
fs := fsx.NewFallbackFS(primary, fsx.NewReadOnlyFs(secondary)) | ||
g.Expect(mustRead(fs, "both.txt")).To(gomega.Equal("primary")) | ||
g.Expect(mustRead(fs, "primary.txt")).To(gomega.Equal("primary")) | ||
g.Expect(mustRead(fs, "secondary.txt")).To(gomega.Equal("secondary")) | ||
|
||
create(fs, "fallback-fs.txt", "fallback-fs") | ||
g.Expect(mustRead(fs, "fallback-fs.txt")).To(gomega.Equal("fallback-fs")) | ||
g.Expect(mustRead(primary, "fallback-fs.txt")).To(gomega.Equal("fallback-fs")) | ||
g.Expect(mustRead(fs.Primary(), "fallback-fs.txt")).To(gomega.Equal("fallback-fs")) | ||
_, err := read(secondary, "fallback-fs.txt") | ||
g.Expect(err).To(gomega.HaveOccurred()) | ||
_, err = read(fs.Secondary(), "fallback-fs.txt") | ||
g.Expect(err).To(gomega.HaveOccurred()) | ||
} | ||
|
||
func TestLayeredFS_Primary(t *testing.T) { | ||
g := gomega.NewWithT(t) | ||
primary := fsx.NewMemMapFs() | ||
fs := fsx.NewFallbackFS(primary, fsx.NewMemMapFs()) | ||
|
||
g.Expect(primary).To(gomega.BeIdenticalTo(fs.Primary().Fs)) | ||
} | ||
|
||
func TestLayeredFS_Secondary(t *testing.T) { | ||
g := gomega.NewWithT(t) | ||
secondary := fsx.NewMemMapFs() | ||
fs := fsx.NewFallbackFS(fsx.NewMemMapFs(), secondary) | ||
|
||
g.Expect(secondary).To(gomega.BeIdenticalTo(fs.Secondary().Fs)) | ||
} |
Oops, something went wrong.