Documentation
¶
Index ¶
- Constants
- func FakeLogin(t *testing.T) (*LoginOutput, *PublicController, *gin.Engine)
- func SetupRouter(c *PublicController) *gin.Engine
- func SetupTestRouter(t *testing.T, controller *PublicController) *gin.Engine
- type GuestInput
- type GuestOutput
- type LoginInput
- type LoginOutput
- type PublicController
- type RefreshOutput
Constants ¶
View Source
const GUEST_ROLE = "guest"
Variables ¶
This section is empty.
Functions ¶
func FakeLogin ¶
func FakeLogin(t *testing.T) (*LoginOutput, *PublicController, *gin.Engine)
Creates fake data both in the database and the returned structure that can be used in tests.
If encounters error fails the test. Database should be cleaned up manually after calling this function. Controller and router can be used in further tests
func SetupRouter ¶
func SetupRouter(c *PublicController) *gin.Engine
We need separate function for router setup to do testing properly
func SetupTestRouter ¶
func SetupTestRouter(t *testing.T, controller *PublicController) *gin.Engine
Types ¶
type GuestInput ¶
type GuestOutput ¶
type LoginInput ¶
type LoginOutput ¶
type PublicController ¶
type PublicController struct { DB *sql.DB AccessTokenCfg models.AccessTokenCfg RefreshTokenCfg models.RefreshTokenCfg GuestServiceURL url.URL LoginServiceURL url.URL Client models.HTTPClient }
func NewController ¶
func NewController(tokensConfig models.TokensCfg, servicesConfig models.ExternalServicesConfig, client models.HTTPClient, db *sql.DB) *PublicController
func SetupTestController ¶
func SetupTestController(t *testing.T, client models.HTTPClient) *PublicController
func (*PublicController) Auth ¶
func (p *PublicController) Auth(c *gin.Context)
Checks if token specified in Authorization header is valid
func (*PublicController) Guest ¶
func (p *PublicController) Guest(c *gin.Context)
Guest registers new guest and returns tokens
func (*PublicController) HealthCheck ¶
func (p *PublicController) HealthCheck(c *gin.Context)
HealthCheck checks if the server is healthy
func (*PublicController) Login ¶
func (p *PublicController) Login(c *gin.Context)
Function that is responsible for user authorization.
In response to a successful authorization request, returns access token and refresh token, as well as the time of death of the access token
func (*PublicController) Refresh ¶
func (p *PublicController) Refresh(c *gin.Context)
type RefreshOutput ¶
Click to show internal directories.
Click to hide internal directories.