本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.HomeDirHomePath方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFileSystem.HomeDirHomePath方法的具體用法?Golang FakeFileSystem.HomeDirHomePath怎麽用?Golang FakeFileSystem.HomeDirHomePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.HomeDirHomePath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: describeLinuxPlatform
//.........這裏部分代碼省略.........
Describe("AddUserToGroups", func() {
It("adds user to groups", func() {
err := platform.AddUserToGroups("foo-user", []string{"group1", "group2", "group3"})
Expect(err).NotTo(HaveOccurred())
Expect(len(cmdRunner.RunCommands)).To(Equal(1))
usermod := []string{"usermod", "-G", "group1,group2,group3", "foo-user"}
Expect(cmdRunner.RunCommands[0]).To(Equal(usermod))
})
})
Describe("DeleteEphemeralUsersMatching", func() {
It("deletes users with prefix and regex", func() {
passwdFile := `bosh_foo:...
bosh_bar:...
foo:...
bar:...
foobar:...
bosh_foobar:...`
fs.WriteFileString("/etc/passwd", passwdFile)
err := platform.DeleteEphemeralUsersMatching("bar$")
Expect(err).NotTo(HaveOccurred())
Expect(len(cmdRunner.RunCommands)).To(Equal(2))
Expect(cmdRunner.RunCommands[0]).To(Equal([]string{"userdel", "-r", "bosh_bar"}))
Expect(cmdRunner.RunCommands[1]).To(Equal([]string{"userdel", "-r", "bosh_foobar"}))
})
})
Describe("SetupSSH", func() {
It("setup ssh", func() {
fs.HomeDirHomePath = "/some/home/dir"
platform.SetupSSH("some public key", "vcap")
sshDirPath := "/some/home/dir/.ssh"
sshDirStat := fs.GetFileTestStat(sshDirPath)
Expect("vcap").To(Equal(fs.HomeDirUsername))
Expect(sshDirStat).NotTo(BeNil())
Expect(sshDirStat.FileType).To(Equal(fakesys.FakeFileTypeDir))
Expect(os.FileMode(0700)).To(Equal(sshDirStat.FileMode))
Expect("vcap").To(Equal(sshDirStat.Username))
authKeysStat := fs.GetFileTestStat(filepath.Join(sshDirPath, "authorized_keys"))
Expect(authKeysStat).NotTo(BeNil())
Expect(fakesys.FakeFileTypeFile).To(Equal(authKeysStat.FileType))
Expect(os.FileMode(0600)).To(Equal(authKeysStat.FileMode))
Expect("vcap").To(Equal(authKeysStat.Username))
Expect("some public key").To(Equal(authKeysStat.StringContents()))
})
})
Describe("SetUserPassword", func() {
It("set user password", func() {
platform.SetUserPassword("my-user", "my-encrypted-password")
Expect(len(cmdRunner.RunCommands)).To(Equal(1))
Expect(cmdRunner.RunCommands[0]).To(Equal([]string{"usermod", "-p", "my-encrypted-password", "my-user"}))
})
})