veyron/services/identity: Make integration test use random post
so multiple test can run simultaneously.

Change-Id: I68e522ed04f36f23e76dbe18f28b5677c4a381fc
diff --git a/services/identity/identityd/identityd_v23_test.go b/services/identity/identityd/identityd_v23_test.go
index c88f7fe..61271b7 100644
--- a/services/identity/identityd/identityd_v23_test.go
+++ b/services/identity/identityd/identityd_v23_test.go
@@ -2,12 +2,14 @@
 
 import (
 	"crypto/tls"
+	"fmt"
 	"io/ioutil"
 	"net/http"
 	"net/http/cookiejar"
 	"strings"
 	"time"
 
+	"v.io/core/veyron/lib/testutil"
 	"v.io/core/veyron/lib/testutil/v23tests"
 )
 
@@ -17,11 +19,11 @@
 	urlRE = "^(https://.*)$"
 )
 
-func seekBlessings(i *v23tests.T, principal *v23tests.Binary) {
+func seekBlessings(i *v23tests.T, principal *v23tests.Binary, httpaddr string) {
 	args := []string{
 		"seekblessings",
 		"--browser=false",
-		"--from=https://localhost:8125/google",
+		fmt.Sprintf("--from=https://%s/google", httpaddr),
 		"-v=3",
 	}
 	inv := principal.Start(args...)
@@ -61,19 +63,27 @@
 func V23TestIdentityServer(i *v23tests.T) {
 	v23tests.RunRootMT(i, "--veyron.tcp.address=127.0.0.1:0")
 
+	// Search for a random unused port.
+	port, err := testutil.FindUnusedPort()
+	if err != nil {
+		i.Fatalf("Unable to find unused port: %v", err)
+	}
+	httpaddr := fmt.Sprintf("localhost:%v", port)
 	// Start the identity server.
 	args := []string{
 		"-host=localhost",
 		"-veyron.tcp.address=127.0.0.1:0",
+		fmt.Sprintf("--httpaddr=%s", httpaddr),
 	}
+
 	i.BuildGoPkg("v.io/core/veyron/services/identity/identityd_test").Start(args...)
 
 	// Use the principal tool to seekblessings.
 	principal := i.BuildGoPkg("v.io/core/veyron/tools/principal")
 	// Test an initial seekblessings call.
-	seekBlessings(i, principal)
+	seekBlessings(i, principal, httpaddr)
 	// Test that a subsequent call succeeds with the same
 	// credentials. This means that the blessings and principal from the
 	// first call works correctly.
-	seekBlessings(i, principal)
+	seekBlessings(i, principal, httpaddr)
 }
diff --git a/services/identity/identityd_test/main.go b/services/identity/identityd_test/main.go
index 8de84d5..0329923 100644
--- a/services/identity/identityd_test/main.go
+++ b/services/identity/identityd_test/main.go
@@ -23,7 +23,7 @@
 var (
 	// Flags controlling the HTTP server
 	host      = flag.String("host", "localhost", "Hostname the HTTP server listens on. This can be the name of the host running the webserver, but if running behind a NAT or load balancer, this should be the host name that clients will connect to. For example, if set to 'x.com', Veyron identities will have the IssuerName set to 'x.com' and clients can expect to find the root name and public key of the signer at 'x.com/blessing-root'.")
-	httpaddr  = flag.String("httpaddr", "localhost:8125", "Address on which the HTTP server listens on.")
+	httpaddr  = flag.String("httpaddr", "localhost:0", "Address on which the HTTP server listens on.")
 	tlsconfig = flag.String("tlsconfig", "", "Comma-separated list of TLS certificate and private key files, in that order. This must be provided.")
 )