fleet/tools
Lucas Manuel Rodriguez 57816592ba
Add read replica testing helpers and fix non-sso login bug (#4908)
not set on the INSERT.
- OUT: Only sets the ID on the passed session and returns it. (`CreatedAt`, `AccessedAt`, are not set.)

New version:

```go
func (ds *Datastore) NewSession(ctx context.Context, userID uint, sessionKey string) (*fleet.Session, error) {
	sqlStatement := `
		INSERT INTO sessions (
			user_id,
			` + "`key`" + `
		)
		VALUES(?,?)
	`
	result, err := ds.writer.ExecContext(ctx, sqlStatement, userID, sessionKey)
	if err != nil {
		return nil, ctxerr.Wrap(ctx, err, "inserting session")
	}

	id, _ := result.LastInsertId() // cannot fail with the mysql driver
	return ds.sessionByID(ctx, ds.writer, uint(id))
}
```

- IN: Define arguments that are truly used when creating a session.
- OUT: Load and return the fleet.Session struct with all values set (using the `ds.writer` to support read replicas correctly).

PS: The new `NewSession` version mimics what we already do with other entities, like policies (`Datastore.NewGlobalPolicy`).
2022-04-04 16:52:05 -07:00
..
api E2e Test: Team admin flow (#4301) 2022-02-21 21:09:36 -05:00
app Sentence Case: Throughout UI, tests, validators, docs (#2455) 2021-10-11 10:58:27 -04:00
backup_db Remove numbers from documentation filenames in Fleet repo (#4313) 2022-02-23 12:17:55 -06:00
bomutils-docker Updates and fixes for packaging (#2682) 2021-10-27 16:17:41 -07:00
ci Make creation of http.Client uniform across the codebase (#3097) 2021-11-24 15:56:54 -05:00
dbutils Add support for context in datastore/mysql layer (#1962) 2021-09-14 08:11:07 -04:00
desktop Add Notarization for Fleet Desktop (#4720) 2022-03-21 15:01:50 -07:00
docker Orbit: Add Fleet Desktop support to Windows (#4873) 2022-04-01 17:28:51 -03:00
file-server Fix update checks for orbit at startup (#3835) 2022-02-23 14:58:07 -03:00
fleetctl-npm Prepare for 4.12.0 (#4797) 2022-03-24 17:24:08 -07:00
loadtesting/terraform Fix codeowners and revert pull 4798 as it stepped on 4834 (#4887) 2022-03-31 12:36:18 -04:00
mysql-replica-testing Add read replica testing helpers and fix non-sso login bug (#4908) 2022-04-04 16:52:05 -07:00
osquery Update README.md 2021-10-12 10:02:31 -05:00
redis-stress Add redis stress (#3363) 2022-01-20 16:18:17 -03:00
redis-tests Add TLS support to Redis connections (#2568) 2021-10-20 10:09:18 -04:00
saml Add multiple users for SSO testing (#2885) 2021-11-10 15:15:41 -08:00
terraform First batch of tf security improvements (#4798) 2022-03-30 13:24:30 -04:00
tuf Orbit: Add Fleet Desktop support to Windows (#4873) 2022-04-01 17:28:51 -03:00
wix-docker Updates and fixes for packaging (#2682) 2021-10-27 16:17:41 -07:00