identitylib

package
v0.1.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package identitylib implements a test identityd service registered using the v.io/x/lib/gosh library.

Index

Constants

This section is empty.

Variables

View Source
var TestIdentityd = gosh.RegisterFunc("TestIdentityd", func() error {

	duration := 365 * 24 * time.Hour

	ctx, shutdown := test.V23Init()
	defer shutdown()

	if flag.CommandLine.Lookup("tls-config").Value.String() == "" {
		addr := *externalHTTPAddr
		if *externalHTTPAddr == "" {
			addr = *httpAddr
		}
		host, _, err := net.SplitHostPort(addr)
		if err != nil {
			return fmt.Errorf("Failed to parse %q: %v", addr, err)
		}
		certFile, keyFile, err := util.WriteCertAndKey(host, duration)
		if err != nil {
			return fmt.Errorf("Could not write cert and key: %v", err)
		}
		if err := flag.CommandLine.Set("tls-config", certFile+","+keyFile); err != nil {
			return fmt.Errorf("Could not set tls-config: %v", err)
		}
	}

	if flag.CommandLine.Lookup("http-addr").Value.String() == flag.CommandLine.Lookup("http-addr").DefValue {
		if err := flag.CommandLine.Set("http-addr", "localhost:"+freePort()); err != nil {
			return fmt.Errorf("Could not set http-addr: %v", err)
		}
	}

	auditor, reader := auditor.NewMockBlessingAuditor()
	revocationManager := revocation.NewMockRevocationManager(ctx)
	oauthProvider := oauth.NewMockOAuth("testemail@example.com", "test-client-id")

	s := server.NewIdentityServer(
		oauthProvider,
		auditor,
		reader,
		revocationManager,
		caveats.NewMockCaveatSelector(),
		"",
		"identity",
		"",
		nil)

	_, eps, externalHTTPAddress := s.Listen(ctx, ctx, *externalHTTPAddr, *httpAddr, *tlsConfig)

	fmt.Printf("TEST_IDENTITYD_NAME=%s\n", eps[0])
	fmt.Printf("TEST_IDENTITYD_HTTP_ADDR=%s\n", externalHTTPAddress)

	<-signals.ShutdownOnSignals(ctx)
	return nil
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL