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 MsSQL DB capabilities to Unit test setup & teardown. #216

Open
2 of 3 tasks
NathanGibbs3 opened this issue Jun 27, 2023 · 4 comments
Open
2 of 3 tasks

Add MsSQL DB capabilities to Unit test setup & teardown. #216

NathanGibbs3 opened this issue Jun 27, 2023 · 4 comments
Assignees
Labels
bug Something isn't working DB Database Issues DB-MsSQL Issues related to Ms SQL Server DB enhancement New feature or request invalid This doesn't seem right Prod Observed in Production Environment. Stability Issue impacts or is related to App Stability. Tests Test Code & Config Issues. Local or CI Environments.
Milestone

Comments

@NathanGibbs3
Copy link
Owner

NathanGibbs3 commented Jun 27, 2023

Item Description
Link to example:
Build Environment: Travis-CI & Local
PHP Version:
PHPUnit Version:
Composer Version:
ADODB Version:
Similar Issues:
Depends on Issue(s):
Dependency Type:
Misc Info: What else might be helpful to know.

Expected Behavior:
The Ability to run PHPUnit test set using MsSQL DB server.
Current Behavior:
Currently Test set only designed to run on MySQL / MariaDB & PostgreSQL.
Solution:

  • Setup MsSQL configuration.
  • Modify tests to use MSSql configuration if requested.
  • Test / Verify.
@NathanGibbs3 NathanGibbs3 added bug Something isn't working invalid This doesn't seem right Tests Test Code & Config Issues. Local or CI Environments. Prod Observed in Production Environment. DB Database Issues New-TechDebt Issue caused by previous commit to this repo. We created it. Stability Issue impacts or is related to App Stability. labels Jun 27, 2023
@NathanGibbs3 NathanGibbs3 added this to the 1.4.6 milestone Jun 27, 2023
@NathanGibbs3 NathanGibbs3 self-assigned this Jun 27, 2023
@NathanGibbs3
Copy link
Owner Author

@mesteele
When you get a chance, can you post the command lines you used to set this up for MsSQL.

I'm sure like MySQL & PostgreSQL, MsSQL has it's own CLI tool with its own unique command line options to do this.

I'll incorporate them into the setup script for the PHPUnit Tests.

@NathanGibbs3 NathanGibbs3 added help wanted Extra attention is needed question Further information is requested labels Jul 2, 2023
@mesteele
Copy link

mesteele commented Jul 3, 2023

@mesteele When you get a chance, can you post the command lines you used to set this up for MsSQL.

I'm sure like MySQL & PostgreSQL, MsSQL has it's own CLI tool with its own unique command line options to do this.

I'll incorporate them into the setup script for the PHPUnit Tests.

I install MSSQL Server as the backend and I've always used the Microsoft SQL Server Management Studio to configure all the BASE stuff.

There is a command line (sqlcmd) for MSSQL but I have never used it. I toyed around with it, and it could take some time to migrate the MySQL/PostgreSQL commands to MSSQL.

SQLCMD

@NathanGibbs3
Copy link
Owner Author

Thank you, that's what I was looking for. 😄

@mesteele
Copy link

mesteele commented Jul 5, 2023

Here is the script that works in windows. It requires SQLCMD mode to be enabled before running the actual script. The line to set that is first Usage: and the second Usage: is running the actual script. They both run from a Windows command prompt.

Script name: mssql_apache.sql

-- This script will create the necessary databases and users for BASE
-- Usage: sqlcmd -E -S WinIDS\SQLEXPRESS -Q "use master"
-- Usage: sqlcmd -S WinIDS\SQLEXPRESS -i D:\winids\activators\db_tools\mssql_apache.sql
--

USE [master]
GO
CREATE DATABASE [archive]
GO
CREATE DATABASE [snort]
GO
USE [snort]
GO
:r d:\winids\apache24\htdocs\base\sql\create_snort_tbls_mssql.sql
GO
:r d:\winids\apache24\htdocs\base\sql\create_base_tbls_mssql.sql
GO
:r d:\winids\apache24\htdocs\base\sql\enable_RI.sql
GO
USE [archive]
GO
:r d:\winids\apache24\htdocs\base\sql\create_snort_tbls_mssql.sql
GO
:r d:\winids\apache24\htdocs\base\sql\create_base_tbls_mssql.sql
GO
:r d:\winids\apache24\htdocs\base\sql\enable_RI.sql
GO
USE [master]
GO
CREATE LOGIN [base] WITH PASSWORD=N'an@l1st', DEFAULT_DATABASE=[snort], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [base]
GO
USE [snort];
GO
USE [archive]
GO
CREATE USER [base] FOR LOGIN [base]
GO
USE [archive];
GO
USE [snort]
GO
CREATE USER [base] FOR LOGIN [base]
GO
USE [master]
GO
CREATE LOGIN [snort] WITH PASSWORD=N'l0gg3r', DEFAULT_DATABASE=[snort], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [snort]
GO
USE [snort]
GO
CREATE USER [snort] FOR LOGIN [snort]
GO
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2
GO

I believe I gave both users full access to both databases (sysadmin) so permissions will need to be tailored for each user?

@NathanGibbs3 NathanGibbs3 added DB-MsSQL Issues related to Ms SQL Server DB enhancement New feature or request and removed help wanted Extra attention is needed question Further information is requested New-TechDebt Issue caused by previous commit to this repo. We created it. labels Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DB Database Issues DB-MsSQL Issues related to Ms SQL Server DB enhancement New feature or request invalid This doesn't seem right Prod Observed in Production Environment. Stability Issue impacts or is related to App Stability. Tests Test Code & Config Issues. Local or CI Environments.
Projects
None yet
Development

No branches or pull requests

2 participants