Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action to promote a user to an admin #59

Merged
merged 36 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0945bc2
Interact with peer data via Secret Storage module
amandahla Oct 3, 2023
a7e5128
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 4, 2023
7969b98
Merge remote-tracking branch 'origin' into ISD-1112-synapse-add-actio…
amandahla Oct 4, 2023
6f0b8d8
Fix typo
amandahla Oct 4, 2023
ee8bc39
Add change-user-admin action
amandahla Oct 4, 2023
d8e32ff
Replace Change for Promote
amandahla Oct 9, 2023
2c9a20a
Change server from optional to str
amandahla Oct 9, 2023
e3ddd99
Remove PebbleServiceError exception
amandahla Oct 9, 2023
d06f34f
Remove BlockedStatus from action
amandahla Oct 9, 2023
49c916a
Expand docstring about peer data
amandahla Oct 9, 2023
527932a
Add AdminAccessTokenNotFoundError exception
amandahla Oct 10, 2023
bfc6be4
Remove _admin_access_token property
amandahla Oct 10, 2023
f2e303b
Add JUJU_HAS_SECRETS constant
amandahla Oct 10, 2023
a8a767e
Use private method to generate authorization header
amandahla Oct 10, 2023
06bf65f
Fix method and add integration test
amandahla Oct 10, 2023
4a77992
Add unit tests
amandahla Oct 10, 2023
cc08310
Make admin_access_token str instead of Optional
amandahla Oct 11, 2023
a3b52b2
Minor fixes
amandahla Oct 11, 2023
6663cdd
Delete promote_user_admin.py
amandahla Oct 11, 2023
f5e2cdc
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 16, 2023
6485564
Fix union-attr error
amandahla Oct 16, 2023
66fbdc5
Add test_enable_saml_success_no_ubuntu_url unit test
amandahla Oct 16, 2023
a92271a
Change import to src-docs work and fix src-docs by removing directory…
amandahla Oct 16, 2023
555b71f
Add get_admin_access_token to the charm so interaction with Secret an…
amandahla Oct 16, 2023
a61bf4d
Fix/remove existing unit tests
amandahla Oct 16, 2023
2dbe265
Add unit tests
amandahla Oct 17, 2023
1591fff
Check for SecretNotFoundError
amandahla Oct 17, 2023
0626ab6
Add more unit tests to make coverage happy
amandahla Oct 17, 2023
7d6daae
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 17, 2023
25cad40
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 18, 2023
4cfcc1b
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 18, 2023
74e113c
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 18, 2023
ecc37dd
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 19, 2023
8dc2388
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 20, 2023
140cc36
Fix log and add test
amandahla Oct 20, 2023
6d99b5c
Merge branch 'main' into ISD-1112-synapse-add-action-to-make-user-an-…
amandahla Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ register-user:
default: false
required:
- username
promote-user-admin:
description: |
Promote a user as a server administrator.
You need to supply a user name.
properties:
username:
description: |
User name to be promoted to admin.
type: string
1 change: 1 addition & 0 deletions generate-src-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

rm -rf src-docs
lazydocs --no-watermark --output-path src-docs src/*
78 changes: 50 additions & 28 deletions src-docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Helper module used to manage interactions with Synapse API.
- **SYNAPSE_PORT**
- **SYNAPSE_URL**
- **ADD_USER_ROOM_URL**
- **PROMOTE_USER_ADMIN_URL**
- **CREATE_ROOM_URL**
- **DEACTIVATE_ACCOUNT_URL**
- **LIST_ROOMS_URL**
Expand All @@ -23,7 +24,7 @@ Helper module used to manage interactions with Synapse API.

---

<a href="../src/synapse/api.py#L96"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L159"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `register_user`

Expand Down Expand Up @@ -61,7 +62,7 @@ Register user.

---

<a href="../src/synapse/api.py#L213"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L276"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_version`

Expand Down Expand Up @@ -90,7 +91,7 @@ We're using retry here because after the config change, Synapse is restarted.

---

<a href="../src/synapse/api.py#L245"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L308"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_access_token`

Expand Down Expand Up @@ -124,7 +125,7 @@ This is a way to do actions on behalf of a user.

---

<a href="../src/synapse/api.py#L274"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L337"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `override_rate_limit`

Expand All @@ -149,7 +150,7 @@ Override user's rate limit.

---

<a href="../src/synapse/api.py#L292"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L353"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_room_id`

Expand Down Expand Up @@ -180,7 +181,7 @@ Get room id.

---

<a href="../src/synapse/api.py#L328"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L389"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `deactivate_user`

Expand All @@ -201,7 +202,7 @@ Deactivate user.

---

<a href="../src/synapse/api.py#L350"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L409"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `create_management_room`

Expand Down Expand Up @@ -231,7 +232,7 @@ Create the management room to be used by Mjolnir.

---

<a href="../src/synapse/api.py#L404"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L461"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `make_room_admin`

Expand All @@ -258,14 +259,35 @@ Make user a room's admin.

---

<a href="../src/synapse/api.py#L43"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L476"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `promote_user_admin`

```python
promote_user_admin(user: User, server: str, admin_access_token: str) → None
```

Promote user to admin.



**Args:**

- <b>`user`</b>: user to be promoted to admin.
- <b>`server`</b>: to be used to promote the user id.
- <b>`admin_access_token`</b>: server admin access token to be used.


---

<a href="../src/synapse/api.py#L45"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `APIError`
Exception raised when something fails while calling the API.

Attrs: msg (str): Explanation of the error.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -287,12 +309,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L59"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L61"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `NetworkError`
Exception raised when requesting API fails due network issues.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -314,12 +336,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L63"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L65"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetNonceError`
Exception raised when getting nonce fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -341,12 +363,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L67"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L69"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetVersionError`
Exception raised when getting version fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -368,12 +390,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L71"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L73"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `VersionUnexpectedContentError`
Exception raised when output of getting version is unexpected.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -395,12 +417,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L75"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L77"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetRoomIDError`
Exception raised when getting room id fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -422,12 +444,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L79"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L81"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetUserIDError`
Exception raised when getting user id fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -449,12 +471,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L83"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L85"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `UserExistsError`
Exception raised when checking if user exists fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -476,12 +498,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L87"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L89"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetAccessTokenError`
Exception raised when getting access token fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -503,12 +525,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L91"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L93"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `RegisterUserError`
Exception raised when registering user fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand Down
29 changes: 26 additions & 3 deletions src-docs/charm.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
# <kbd>module</kbd> `charm.py`
Charm for Synapse on kubernetes.

**Global Variables**
---------------
- **JUJU_HAS_SECRETS**
- **PEER_RELATION_NAME**
- **SECRET_ID**
- **SECRET_KEY**


---

## <kbd>class</kbd> `SynapseCharm`
Charm the service.

<a href="../src/charm.py#L32"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L41"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -69,7 +75,7 @@ Unit that this execution is responsible for.

---

<a href="../src/charm.py#L89"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L101"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `change_config`

Expand All @@ -81,7 +87,24 @@ Change configuration.

---

<a href="../src/charm.py#L79"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L211"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `get_admin_access_token`

```python
get_admin_access_token() → Optional[str]
```

Get admin access token.



**Returns:**
admin access token or None if fails.

---

<a href="../src/charm.py#L91"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `replan_nginx`

Expand Down
15 changes: 14 additions & 1 deletion src-docs/charm_state.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,20 @@ Configuration for accessing Synapse through proxy.
## <kbd>class</kbd> `SynapseConfig`
Represent Synapse builtin configuration values.

Attrs: server_name: server_name config. report_stats: report_stats config. public_baseurl: public_baseurl config. enable_mjolnir: enable_mjolnir config. smtp_enable_tls: enable tls while connecting to SMTP server. smtp_host: SMTP host. smtp_notif_from: defines the "From" address to use when sending emails. smtp_pass: password to authenticate to SMTP host. smtp_port: SMTP port. smtp_user: username to autehtncate to SMTP host.


**Attributes:**

- <b>`server_name`</b>: server_name config.
- <b>`report_stats`</b>: report_stats config.
- <b>`public_baseurl`</b>: public_baseurl config.
- <b>`enable_mjolnir`</b>: enable_mjolnir config.
- <b>`smtp_enable_tls`</b>: enable tls while connecting to SMTP server.
- <b>`smtp_host`</b>: SMTP host.
- <b>`smtp_notif_from`</b>: defines the "From" address to use when sending emails.
- <b>`smtp_pass`</b>: password to authenticate to SMTP host.
- <b>`smtp_port`</b>: SMTP port.
- <b>`smtp_user`</b>: username to authenticate to SMTP host.



Expand Down
35 changes: 0 additions & 35 deletions src-docs/constants.py.md

This file was deleted.

Loading
Loading