tools

package
v0.0.0-...-f28940e Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertByteResp

func ConvertByteResp(resp *http.Response) []byte

responseをbytesに変換する

func ConvertResp

func ConvertResp(resp *http.Response) string

responseをstringに変換する

func SetCookie

func SetCookie(jar *cookiejar.Jar, key string, value string, exp *net.CookieExp, url *url.URL)

cookieをセットする テスト用

Types

type DummyUser

type DummyUser struct {
	UserID   string
	Mail     string
	Otp      *secure.OnetimePassword
	Roles    []string
	AccessID string
}

func NewDummyUser

func NewDummyUser() *DummyUser

func (*DummyUser) AddLoginToken

func (c *DummyUser) AddLoginToken(ctx context.Context, db *database.Database, now time.Time) (string, string, error)

session-tokenとrefresh-tokenをセットする テスト用

func (*DummyUser) AddRole

func (c *DummyUser) AddRole(role string) *DummyUser

Roleを追加する

func (*DummyUser) AddUserCert

func (c *DummyUser) AddUserCert(ctx context.Context, db *database.Database) (*models.Certification, error)

ユーザの認証情報を追加する (テスト用)

func (*DummyUser) AddUserInfo

func (c *DummyUser) AddUserInfo(ctx context.Context, db *database.Database) (*models.User, error)

ユーザを追加する (テスト用)

func (*DummyUser) GenOTPCode

func (c *DummyUser) GenOTPCode() (string, error)

OTPのパスコードを生成する

func (*DummyUser) NewOTP

func (c *DummyUser) NewOTP() (*DummyUser, error)

OTPをセットする

type TestServer

type TestServer struct {
	Server       *httptest.Server
	Client       *http.Client
	Jar          *cookiejar.Jar
	Dummy        *DummyUser
	Url          *url.URL
	SessionToken string
	RefreshToken string
}

func NewTestServer

func NewTestServer(t *testing.T, handler http.Handler, isCookie bool) *TestServer

func (*TestServer) AddSession

func (c *TestServer) AddSession(ctx context.Context, db *database.Database, dummy *DummyUser) error

cookieにセッション情報を追加する

func (*TestServer) Close

func (c *TestServer) Close()

func (*TestServer) Delete

func (c *TestServer) Delete(t *testing.T, path string) *http.Response

func (*TestServer) FindCookies

func (c *TestServer) FindCookies(t *testing.T, cookies []string)

cookieが存在するかをチェックする

func (*TestServer) Get

func (c *TestServer) Get(t *testing.T, path string) *http.Response

func (*TestServer) GetCookie

func (c *TestServer) GetCookie(key string) string

func (*TestServer) Head

func (c *TestServer) Head(t *testing.T, path string) *http.Response

func (*TestServer) Post

func (c *TestServer) Post(t *testing.T, path string, form interface{}) *http.Response

func (*TestServer) PostForm

func (c *TestServer) PostForm(t *testing.T, path string, form url.Values) *http.Response

Jump to

Keyboard shortcuts

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