gopkg.in/goose.v2@v2.0.1/testservices/identityservice/util.go (about)

     1  package identityservice
     2  
     3  import (
     4  	"crypto/rand"
     5  	"encoding/hex"
     6  	"fmt"
     7  	"io"
     8  )
     9  
    10  type UserInfo struct {
    11  	Id         string
    12  	TenantId   string
    13  	TenantName string
    14  	Token      string
    15  	secret     string
    16  	authDomain string
    17  }
    18  
    19  var randReader = rand.Reader
    20  
    21  // Generate a bit of random hex data for
    22  func randomHexToken() string {
    23  	raw_bytes := make([]byte, 16)
    24  	n, err := io.ReadFull(randReader, raw_bytes)
    25  	if err != nil {
    26  		panic(fmt.Sprintf(
    27  			"failed to read 16 random bytes (read %d bytes): %s",
    28  			n, err.Error()))
    29  	}
    30  	hex_bytes := make([]byte, 32)
    31  	// hex.Encode can't fail, no error checking needed.
    32  	hex.Encode(hex_bytes, raw_bytes)
    33  	return string(hex_bytes)
    34  }