Skip to content

Commit

Permalink
Fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
getvictor committed Dec 27, 2024
1 parent de69aef commit 47f3c9a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions server/datastore/mysql/apple_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4411,7 +4411,7 @@ INSERT INTO mdm_apple_declarations (
checksum,
secrets_updated_at,
uploaded_at)
(SELECT ?,?,?,?,?,UNHEX(MD5(raw_json)),?,CURRENT_TIMESTAMP() FROM DUAL WHERE
(SELECT ?,?,?,?,?,UNHEX(MD5(?)),?,CURRENT_TIMESTAMP() FROM DUAL WHERE
NOT EXISTS (
SELECT 1 FROM mdm_windows_configuration_profiles WHERE name = ? AND team_id = ?
) AND NOT EXISTS (
Expand All @@ -4433,7 +4433,7 @@ INSERT INTO mdm_apple_declarations (
checksum,
secrets_updated_at,
uploaded_at)
(SELECT ?,?,?,?,?,UNHEX(MD5(raw_json)),?,CURRENT_TIMESTAMP() FROM DUAL WHERE
(SELECT ?,?,?,?,?,UNHEX(MD5(?)),?,CURRENT_TIMESTAMP() FROM DUAL WHERE
NOT EXISTS (
SELECT 1 FROM mdm_windows_configuration_profiles WHERE name = ? AND team_id = ?
) AND NOT EXISTS (
Expand Down Expand Up @@ -4461,7 +4461,8 @@ func (ds *Datastore) insertOrUpsertMDMAppleDeclaration(ctx context.Context, insO

err := ds.withTx(ctx, func(tx sqlx.ExtContext) error {
res, err := tx.ExecContext(ctx, insOrUpsertStmt,
declUUID, tmID, declaration.Identifier, declaration.Name, declaration.RawJSON, declaration.SecretsUpdatedAt,
declUUID, tmID, declaration.Identifier, declaration.Name, declaration.RawJSON, declaration.RawJSON,
declaration.SecretsUpdatedAt,
declaration.Name, tmID, declaration.Name, tmID)
if err != nil {
switch {
Expand Down
1 change: 1 addition & 0 deletions server/datastore/mysql/microsoft_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@ WHERE
team_id = ?
`

// For Windows profiles, if team_id and name are the same, we do an update. Otherwise, we do an insert.
const insertNewOrEditedProfile = `
INSERT INTO
mdm_windows_configuration_profiles (
Expand Down
4 changes: 2 additions & 2 deletions server/service/mdm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2113,8 +2113,8 @@ func TestBatchSetMDMProfilesLabels(t *testing.T) {
ds.ValidateEmbeddedSecretsFunc = func(ctx context.Context, documents []string) error {
return nil
}
ds.ExpandEmbeddedSecretsFunc = func(ctx context.Context, document string) (string, error) {
return document, nil
ds.ExpandEmbeddedSecretsAndUpdatedAtFunc = func(ctx context.Context, document string) (string, *time.Time, error) {
return document, nil, nil
}

profiles := []fleet.MDMProfileBatchPayload{
Expand Down

0 comments on commit 47f3c9a

Please sign in to comment.