(t *testing.T)
| 130 | } |
| 131 | |
| 132 | func TestGetContext(t *testing.T) { |
| 133 | // Setup |
| 134 | gin.SetMode(gin.TestMode) |
| 135 | c, _ := gin.CreateTestContext(nil) |
| 136 | |
| 137 | // Normal case |
| 138 | c.Set("context", &config.UserContext{Username: "testuser"}) |
| 139 | result, err := utils.GetContext(c) |
| 140 | assert.NilError(t, err) |
| 141 | assert.Equal(t, "testuser", result.Username) |
| 142 | |
| 143 | // Case with no context |
| 144 | c.Set("context", nil) |
| 145 | _, err = utils.GetContext(c) |
| 146 | assert.Error(t, err, "invalid user context in request") |
| 147 | |
| 148 | // Case with invalid context type |
| 149 | c.Set("context", "invalid type") |
| 150 | _, err = utils.GetContext(c) |
| 151 | assert.Error(t, err, "invalid user context in request") |
| 152 | } |
| 153 | |
| 154 | func TestIsRedirectSafe(t *testing.T) { |
| 155 | // Setup |
nothing calls this directly
no test coverage detected