mirror of
https://github.com/ceph/go-ceph
synced 2024-12-24 23:22:33 +00:00
29c88f4b2d
The Init functions initializes the connection without mounting the fs. This function must be called before setting the perms but before creating the mount. SetMountPerms accepts a UserPerm object to set the fs ownership info on the mount. The corresponding tests verifies that the UserPerm can be applied and it effects the gid of newly created dirs for that mount. Signed-off-by: John Mulligan <jmulligan@redhat.com>
46 lines
987 B
Go
46 lines
987 B
Go
// +build !luminous
|
|
|
|
package cephfs
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"syscall"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSetMountPerms(t *testing.T) {
|
|
mount, err := CreateMount()
|
|
require.NoError(t, err)
|
|
require.NotNil(t, mount)
|
|
defer func() { assert.NoError(t, mount.Release()) }()
|
|
|
|
err = mount.ReadDefaultConfigFile()
|
|
require.NoError(t, err)
|
|
|
|
err = mount.Init()
|
|
assert.NoError(t, err)
|
|
|
|
uperm := NewUserPerm(0, 500, []int{0, 500, 501})
|
|
err = mount.SetMountPerms(uperm)
|
|
assert.NoError(t, err)
|
|
|
|
err = mount.Mount()
|
|
assert.NoError(t, err)
|
|
defer func() { assert.NoError(t, mount.Unmount()) }()
|
|
|
|
t.Run("checkStat", func(t *testing.T) {
|
|
useMount(t)
|
|
dirname := "/check-mount-perms"
|
|
err := mount.MakeDir(dirname, 0755)
|
|
assert.NoError(t, err)
|
|
defer mount.RemoveDir(dirname)
|
|
s, err := os.Stat(path.Join(CephMountDir, dirname))
|
|
require.NoError(t, err)
|
|
assert.EqualValues(t, s.Sys().(*syscall.Stat_t).Gid, 500)
|
|
})
|
|
}
|