mockusso

package
v1.12.3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is a http.Handler that provides a mock implementation of Ubuntu SSO. It is designed to closely match the responses provided by Ubuntu SSO providing openid login and oauth verification.

func New

func New(location string) *Handler

func (*Handler) AddUser

func (h *Handler) AddUser(u *User)

AddUser adds u to the handles user database.

func (*Handler) ExcludeExtensions

func (h *Handler) ExcludeExtensions()

ExcludeExtensions prevents an OpenID login response from including any extensions.

func (*Handler) Login

Login handles OpenID login requests.

func (*Handler) Reset

func (h *Handler) Reset()

Reset sets all of the state in the Handler back to the default. This should be called between tests.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Handler) SetLoginUser

func (h *Handler) SetLoginUser(user string)

SetLoginUser sets the user that is logged in when an OpenID request is recieved.

type Server

type Server struct {
	MockUSSO *Handler
	// contains filtered or unexported fields
}

Server represents a mock USSO server.

func NewServer

func NewServer() *Server

NewServer starts a mock USSO server and also modifies http.DefaultTransport to redirect requests addressed to https://login.ubuntu.com to it.

The returned Server must be closed after use.

func (*Server) Close

func (s *Server) Close()

type User

type User struct {
	ID       string
	NickName string
	FullName string
	Email    string
	Groups   []string

	// OAuth Credentials
	ConsumerSecret string
	TokenKey       string
	TokenSecret    string
}

Jump to

Keyboard shortcuts

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