Skip to content

Conversation

@baburciu
Copy link

@baburciu baburciu commented Dec 5, 2025

Description of your changes

Related to #258 (comment), it adds e2e integration tests for MSSQL.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Tested locally on Ubuntu 24.04.1 LTS. Have commented out the cleanups and could confirm it like this:

$ kubectl get Database,Grant,User
NAME                                          READY   SYNCED   AGE
database.mssql.sql.crossplane.io/example-db   True    True     4m8s

NAME                                          READY   SYNCED   AGE     ROLE           DATABASE     SCHEMA   PERMISSIONS
grant.mssql.sql.crossplane.io/example-grant   True    True     3m55s   example-user   example-db            ["CONNECT","CREATE TABLE","INSERT","SELECT"]

NAME                                        READY   SYNCED   AGE
user.mssql.sql.crossplane.io/example-user   True    True     4m5s
$
$ kubectl exec -it mssql-0 -- /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$(kubectl get secret mssql-creds -o jsonpath='{.data.password}' | base64 -d)" -C -d example-db -Q "SELECT name FROM sys.database_principals WHERE name = 'example-user'"
name
--------------------------------------------------------------------------------------------------------------------------------
example-user

(1 rows affected)
$ kubectl exec -it mssql-0 -- /opt/mssql-tools18/bin/sqlcmd -S localhost -U example-user -P "$(kubectl get secret example-pw -o jsonpath='{.data.password}' | base64 -d)" -C -d example-db -Q "SELECT DB_NAME() AS DatabaseName"
DatabaseName
--------------------------------------------------------------------------------------------------------------------------------
example-db

(1 rows affected)
$ kubectl exec -it mssql-0 -- /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$(kubectl get secret mssql-creds -o jsonpath='{.data.password}' | base64 -d)" -C -d example-db -Q "SELECT dp.permission_name, dp.state_desc, pr.name AS principal_name FROM sys.database_permissions dp JOIN sys.database_principals pr ON dp.grantee_principal_id = pr.principal_id WHERE pr.name = 'example-user'"
permission_name                                                                                                                  state_desc                                                   principal_name
-------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------ --------------------------------------------------------------------------------------------------------------------------------
CONNECT                                                                                                                          GRANT                                                        example-user
CREATE TABLE                                                                                                                     GRANT                                                        example-user
INSERT                                                                                                                           GRANT                                                        example-user
SELECT                                                                                                                           GRANT                                                        example-user

(4 rows affected)
$

Signed-off-by: Bogdan-Adrian Burciu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant