Files
openobserve/tests
Subhra264 bcdace5459 fix: Root user should not be added to any organization (#8632)
### **User description**
Root user by default can access all the organizations and does not need
to be added to any organizations through api.


___

### **PR Type**
Bug fix, Tests


___

### **Description**
- Prevent adding root user to orgs

- Return Forbidden for unauthorized add attempts

- Expand integration tests for user/org flows

- Validate user listing includes expected emails


___

### Diagram Walkthrough


```mermaid
flowchart LR
  addUser["add_user_to_org handler"] -- "user is root" --> rejectRoot["400 Bad Request: root no org needed"]
  addUser -- "not root & unauthorized" --> forbid["403 Forbidden"]
  tests["Integration tests"] -- "root add attempt" --> expect400["expect failure"]
  tests -- "create non-root & add to org" --> expect200["expect success"]
  tests -- "list users" --> assertUsers["assert expected emails present"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>users.rs</strong><dd><code>Block root user org add; use
403 for denial</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

src/service/users.rs

<ul><li>Short-circuit if <code>existing_user.is_root</code>, return
400.<br> <li> Change unauthorized response from 401 to 403.<br> <li> Add
explanatory comments for root access.</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8632/files#diff-98da2588a28d62bb2e301d989836125f89f89b76272cd7f75e08ec4deeea5f38">+13/-2</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>integration_test.rs</strong><dd><code>Extend
integration tests for user/org behaviors</code>&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

tests/integration_test.rs

<ul><li>Import <code>UserList</code> and validate list users
content.<br> <li> Add <code>e2e_add_root_user_to_org</code> expecting
failure.<br> <li> Add <code>e2e_add_user_to_org</code> to create and add
admin user.<br> <li> Update test sequence to include new cases.</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8632/files#diff-7ff815b68943f08bef79f083c09e55ca8c18db8e25033034b12fa31f1d43dab4">+79/-2</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___
2025-09-29 11:53:15 +05:30
..
2025-08-27 18:24:39 +05:30
2024-09-22 17:57:47 +08:00