v.io: v.io/x/ref/services/identity/identitylib Index | Files

package identitylib

import "v.io/x/ref/services/identity/identitylib"

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

Index

Package Files

test_identityd.go

Variables

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
})

Package identitylib imports 14 packages (graph). Updated 2020-09-08. Refresh now. Tools for package owners.