Exemplo n.º 1
0
func main() {
	flag.StringVar(&flagBlobstoreSecret, "secret", "", "The secret for signing webdav url")
	flag.StringVar(&flagNetwork, "network", "", "Network type")
	flag.StringVar(&flagLocalAddress, "laddr", "", "Local network address")
	flag.Parse()

	urlSigner := signer.NewSigner(flagBlobstoreSecret)
	serverHandlers := server.NewServerHandlers(urlSigner)

	if flagNetwork == "unix" {
		os.Remove(flagLocalAddress)
	}

	s := server.NewServer(flagNetwork, flagLocalAddress, serverHandlers)
	s.Start()
}
Exemplo n.º 2
0
)

var _ = Describe("Signer", func() {

	Context("Sign", func() {

		It("removes all =", func() {
		})

		It("returns a signed URL", func() {
			expires := "2147483647"
			secret := "secret"
			path := "/s/link"
			clientIp := "127.0.0.1"

			signer := signer.NewSigner(expires, secret, path, clientIp)
			signedUrl := signer.Sign()
			Expect(signedUrl).To(Equal("/s/link?md5=_e4Nc3iduzkWRm01TBBNYw&expires=2147483647"))
		})
	})

	Context("SanitizeString", func() {
		It("replaces '/' with '_'", func() {
			sanitizedString := signer.SanitizeString("i am /a /string")
			Expect(sanitizedString).To(Equal("i am _a _string"))
		})

		It("replaces '+' with '-'", func() {
			sanitizedString := signer.SanitizeString("i am +a +string")
			Expect(sanitizedString).To(Equal("i am -a -string"))
		})