[PR #1019] [MERGED] Fix DefaultAccountManager GetGroupsFromTheToken false positive tests #13229

Closed
opened 2026-08-05 02:07:50 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/1019
Author: @surik
Created: 7/18/2023
Status: Merged
Merged: 7/22/2023
Merged by: @gigovich

Base: mainHead: fix-test-when-account-id-is-nil


📝 Commits (1)

  • 84d6cc7 Fix DefaultAccountManager GetGroupsFromTheToken false positive tests

📊 Changes

2 files changed (+12 additions, -2 deletions)

View changed files

📝 management/server/account_test.go (+8 -2)
📝 management/server/file_store.go (+4 -0)

📄 Description

Describe your changes

This pull request addresses an issue discovered while working on an alternative implementation of the Store module. The issue relates to the current behavior of the SaveAccount functionality, which allows creating an account with an empty ID and fails to validate if the indices are being repointed to another account.

To provide more context, the problem manifests in the following test cases:

  1. The newAccountWithId("", userId, domain) function is called, resulting in an account with an admin user but an empty account ID.
  2. Subsequently, manager.GetAccountByUserOrAccountID(userId, initAccount.Id, domain) is executed, which creates an account using the same function from the previous step, but this time providing an ID. This account is stored in FileStore.
  3. Within the test cases, certain settings are applied to the initial account with an empty ID, and this account is then stored.
  4. The tests pass because manager.GetAccountFromToken(claims) is able to locate an account based on the user ID specified in the claim.

The proposed changes in this pull request aim to enhance the existing functionality. Instead of creating new accounts during the tests, the changes ensure that the existing accounts are updated. Additionally, an extra check is introduced to validate the Account ID in the SaveAccount operation.

While this issue may not have a direct impact on production, ensuring the correctness of the tests can have future benefits. By maintaining reliable and accurate tests, we promote the stability and reliability of the codebase.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/1019 **Author:** [@surik](https://github.com/surik) **Created:** 7/18/2023 **Status:** ✅ Merged **Merged:** 7/22/2023 **Merged by:** [@gigovich](https://github.com/gigovich) **Base:** `main` ← **Head:** `fix-test-when-account-id-is-nil` --- ### 📝 Commits (1) - [`84d6cc7`](https://github.com/netbirdio/netbird/commit/84d6cc75f65438982b6d39a5c0ad6834e731daf4) Fix DefaultAccountManager GetGroupsFromTheToken false positive tests ### 📊 Changes **2 files changed** (+12 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `management/server/account_test.go` (+8 -2) 📝 `management/server/file_store.go` (+4 -0) </details> ### 📄 Description ## Describe your changes This pull request addresses an issue discovered while working on an alternative implementation of the Store module. The issue relates to the current behavior of the SaveAccount functionality, which allows creating an account with an empty ID and fails to validate if the indices are being repointed to another account. To provide more context, the problem manifests in the following test cases: 1. The `newAccountWithId("", userId, domain)` function is called, resulting in an account with an admin user but an empty account ID. 2. Subsequently, `manager.GetAccountByUserOrAccountID(userId, initAccount.Id, domain)` is executed, which creates an account using the same function from the previous step, but this time providing an ID. This account is stored in FileStore. 3. Within the test cases, certain settings are applied to the initial account with an empty ID, and this account is then stored. 4. The tests pass because `manager.GetAccountFromToken(claims)` is able to locate an account based on the user ID specified in the claim. The proposed changes in this pull request aim to enhance the existing functionality. Instead of creating new accounts during the tests, the changes ensure that the existing accounts are updated. Additionally, an extra check is introduced to validate the Account ID in the SaveAccount operation. While this issue may not have a direct impact on production, ensuring the correctness of the tests can have future benefits. By maintaining reliable and accurate tests, we promote the stability and reliability of the codebase. ## Issue ticket number and link ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 02:07:50 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#13229