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()
}
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

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

	var (
		fakeSigner    *fakes.FakeSigner
		serverHandler server.ServerHandlers
		resp          *httptest.ResponseRecorder
	)

	BeforeEach(func() {
		fakeSigner = &fakes.FakeSigner{}
		serverHandler = server.NewServerHandlers(fakeSigner)
		resp = httptest.NewRecorder()
	})

	Describe("SignUrl()", func() {
		It("calls the signer to sign the url", func() {
			serverHandler.SignUrl(resp, &http.Request{})
			Expect(fakeSigner.SignCallCount()).To(Equal(1))
		})

		It("writes the signed URL back to requester", func() {
			fakeSigner.SignReturns("/link/?md5=signedurl")
			serverHandler.SignUrl(resp, &http.Request{})
			Expect(resp.Body.String()).To(Equal("/link/?md5=signedurl"))
		})
	})