Documentation
¶
Overview ¶
Package admintest is a stand-in for go-fileshare/portal and the fileshare servers behind it, for tests: in one process, with the portal's rules where the console depends on them.
- every call must carry Portal-Request: 1, or it is refused (403);
- a session holds tokens only for the servers its last refresh named, and a call to another answers 401 with Portal-Refresh: <server>;
- refreshes are counted, and two that overlap are reported, because a provider that rotates refresh tokens would end the login there.
Behind it each server is a real Connect server (connect-go, the same generated handler interface fileshare implements) over a map of shares.
Index ¶
- func Share(name, dir string, subject string, write bool) *v1.Share
- type Portal
- type Server
- func (s *Server) CreateShare(_ context.Context, r *v1.CreateShareRequest) (*v1.CreateShareResponse, error)
- func (s *Server) DeleteShare(_ context.Context, r *v1.DeleteShareRequest) (*v1.DeleteShareResponse, error)
- func (s *Server) DisableShare(_ context.Context, r *v1.DisableShareRequest) (*v1.DisableShareResponse, error)
- func (s *Server) EnableShare(_ context.Context, r *v1.EnableShareRequest) (*v1.EnableShareResponse, error)
- func (s *Server) GetServerInfo(context.Context, *v1.GetServerInfoRequest) (*v1.GetServerInfoResponse, error)
- func (s *Server) Grant(_ context.Context, r *v1.GrantRequest) (*v1.GrantResponse, error)
- func (s *Server) ListShares(context.Context, *v1.ListSharesRequest) (*v1.ListSharesResponse, error)
- func (s *Server) Names() []string
- func (s *Server) Revoke(_ context.Context, r *v1.RevokeRequest) (*v1.RevokeResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Portal ¶
type Portal struct {
*httptest.Server
Refreshes atomic.Int64
Overlapping atomic.Int64 // refreshes that began while another ran
// Delay makes each refresh take this long, so that overlaps can happen.
Delay time.Duration
// MaxTokens, when > 0, refuses a refresh for more servers (413), as the
// portal does past its cookie budget.
MaxTokens int
// NoHeader counts calls that came without Portal-Request.
NoHeader atomic.Int64
// contains filtered or unexported fields
}
Portal is the fake portal.
type Server ¶
type Server struct {
adminv1connect.UnimplementedAdminServiceHandler
ID, Label string
Reachable bool
// Calls counts the calls that reached this server.
Calls atomic.Int64
// Fail, when set, is answered to every call.
Fail error
// contains filtered or unexported fields
}
Server is one fake fileshare server.
func (*Server) CreateShare ¶
func (s *Server) CreateShare(_ context.Context, r *v1.CreateShareRequest) (*v1.CreateShareResponse, error)
func (*Server) DeleteShare ¶
func (s *Server) DeleteShare(_ context.Context, r *v1.DeleteShareRequest) (*v1.DeleteShareResponse, error)
func (*Server) DisableShare ¶
func (s *Server) DisableShare(_ context.Context, r *v1.DisableShareRequest) (*v1.DisableShareResponse, error)
func (*Server) EnableShare ¶
func (s *Server) EnableShare(_ context.Context, r *v1.EnableShareRequest) (*v1.EnableShareResponse, error)
func (*Server) GetServerInfo ¶
func (s *Server) GetServerInfo(context.Context, *v1.GetServerInfoRequest) (*v1.GetServerInfoResponse, error)
func (*Server) Grant ¶
func (s *Server) Grant(_ context.Context, r *v1.GrantRequest) (*v1.GrantResponse, error)
func (*Server) ListShares ¶
func (s *Server) ListShares(context.Context, *v1.ListSharesRequest) (*v1.ListSharesResponse, error)
func (*Server) Revoke ¶
func (s *Server) Revoke(_ context.Context, r *v1.RevokeRequest) (*v1.RevokeResponse, error)
Click to show internal directories.
Click to hide internal directories.