* refactor(clients): deprecate RetrieveNames
Remove RetrieveNames and modify RetrieveAllBasicInfo to replace it. Remove sensitive information when retrieving basic information
* change from if statement to switch
Co-authored-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
---------
Co-authored-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
* feat: add retrieve users by name
Retrieve users by name from the database. This is a new feature. It
enables the user to retrieve users by name.
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
* test: bump up test cases
The changes made in this commit involve modifying the RetrieveNames function in the clients.go file. The function now retrieves client names by constructing a query. Additionally, test cases have been added to ensure the correct retrieval of clients with different parameters and to assert the expected response and error values.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix: add direction only when we have order
When constructing a query, the function now checks if the order parameter is provided and if it is one of the allowed values (name, identity, created_at, updated_at). If so, the function adds an ORDER BY clause to the query. Additionally, if the direction parameter is provided and it is either "asc" or "desc", the function adds the direction to the query.
This change enables users to specify the order in which the query results should be returned and the direction of the ordering.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix: fix sorting direction check in constructQuery
The fix updates the check to use the constants from the api package for clarity and consistency.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(users): add ID field to RetrieveNames query
Added the ID field to the SELECT query in the RetrieveNames function in clients.go. This change allows the function to retrieve the ID along with the name of the clients.
Also modified the clients_test.go file to include the ID field in the test data for the RetrieveNames test.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(db): Test for SQL injection
This commit adds a new feature by including a username field in the client information. It also modifies the retrieval of client names and adds tests to prevent SQL injection. Additionally, it introduces functions for retrieving clients based on their identity and includes test functions for retrieving clients based on different criteria. The code also includes functions for setting parameters and finding clients based on specific queries.
* feat(users): update SQL query in RetrieveNames
This commit updates the SQL query in the RetrieveNames function in the users/postgres/clients.go file. The query now uses the '~' operator instead of 'ILIKE' for the name and identity conditions. This change improves the search functionality by allowing for more flexible matching.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* remove: UpdateClientOwner from things service
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix: user role update, listing and retrieve
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix: add user to have dual relationship to platform, so for update role just add or remove admin relation
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: users permission sdk
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix: grammer
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
* feat(users): add unique constraint to clients name
This commit adds a new migration to the users. The migration adds a unique constraint to the "clients" table in the database. This constraint ensures that the "name" column of the "clients" table is unique.
* feat: add tests
This commit adds constraints to the PostgreSQL database code for saving clients. Specifically, it ensures that the name column is not null and unique.
The code includes test cases with descriptions, client objects, and expected errors to cover scenarios such as adding clients successfully. These changes enhance the functionality and reliability of the codebase.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix: no need for seperate migration
This commit fixes an issue in the clients table in the PostgreSQL database. The name column is now set to NOT NULL and UNIQUE, ensuring that every client has a name and that the name is unique. This change improves data integrity and prevents any potential data inconsistencies.
Note: This commit does not include the clients_02 migration as it has been removed.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* chore(license): update copyright notices
Add CI check for non go files to check that the files contain a license
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix(ci): log failed files
When the CI fails during check for license header, log the failed file to console so that someone can check on the actual file. Also simplify the grep check to make it more human readable and understandable
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>