users

package
v0.0.0-...-b2e0f1d Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeedsSiteInit

func NeedsSiteInit(baseURL string) (bool, string, error)

NeedsSiteInit returns true if the instance hasn't done "Site admin init" step.

Types

type Client

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

Client is an authenticated client for a Sourcegraph user for doing e2e testing. The user may or may not be a site admin depends on how the client is instantiated. It works by simulating how the browser would send HTTP requests to the server.

func NewClient

func NewClient(baseURL string, requestLogger, responseLogger logFunc) (*Client, error)

NewClient instantiates a new client by performing a GET request then obtains the CSRF token and cookie from its response, if there is one (old versions of Sourcegraph only). If request- or responseLogger are provided, the request and response bodies, respectively, will be written to them for any GraphQL requests only.

func SiteAdminInit

func SiteAdminInit(baseURL, email, username, password string) (*Client, error)

SiteAdminInit initializes the instance with given admin account. It returns an authenticated client as the admin for doing testing.

func (*Client) CreateAccessToken

func (c *Client) CreateAccessToken(token string, scopes []string, note string) (string, error)

CreateAccessToken creates an access token for the current user. An optional token can be passed to impersonate other users.

func (*Client) CurrentUserID

func (c *Client) CurrentUserID(token string) (string, error)

CurrentUserID returns the current authenticated user's GraphQL node ID. An optional token can be passed to impersonate other users.

func (*Client) GraphQL

func (c *Client) GraphQL(token, query string, variables map[string]any, target any) error

GraphQL makes a GraphQL request to the server on behalf of the user authenticated by the client. An optional token can be passed to impersonate other users. A nil target will skip unmarshalling the returned JSON response.

Jump to

Keyboard shortcuts

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