Skip to content

Commit d75a977

Browse files
committed
add sensitivity classification unit test
1 parent 7c25b22 commit d75a977

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/sp_doc.Tests.sql

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,52 @@ IF (@TargetRows > @ReturnedRows)
187187
END;
188188
GO
189189

190+
/*
191+
test sp_doc succeeds with Sensitivity Classification
192+
*/
193+
CREATE PROCEDURE [sp_doc].[test sp succeeds with Sensitivity Classification]
194+
AS
195+
BEGIN;
196+
197+
--TODO: Upgrade this to use SKIP functionality when tSQLt is upgraded - https://github.com/LowlyDBA/dba-multitool/issues/165
198+
199+
--Rows returned from empty database
200+
DECLARE @SqlMajorVersion TINYINT;
201+
DECLARE @Verbose BIT = 0;
202+
DECLARE @DatabaseName SYSNAME = 'tSQLt';
203+
DECLARE @FailMessage NVARCHAR(MAX) = N'Did not find test sensitivity classifications in output.';
204+
205+
DECLARE @Expected NVARCHAR(1000) = N'%Label: Highly Confidential <br /> Type: Financial <br /> Rank: CRITICAL <br />%';
206+
207+
SET @SqlMajorVersion = CAST(SERVERPROPERTY('ProductMajorVersion') AS TINYINT);
208+
209+
IF (@SqlMajorVersion >= 15)
210+
BEGIN
211+
--Setup
212+
IF OBJECT_ID('tempdb..#result') IS NOT NULL
213+
BEGIN
214+
DROP TABLE #result;
215+
END
216+
CREATE TABLE #result ([markdown] NVARCHAR(MAX));
217+
218+
ADD SENSITIVITY CLASSIFICATION TO [tSQLt].[CaptureOutputLog].[OutputText]
219+
WITH (LABEL='Highly Confidential', INFORMATION_TYPE='Financial', RANK=CRITICAL)
220+
221+
--Get results
222+
INSERT INTO #result
223+
EXEC sp_doc @DatabaseName = @DatabaseName, @Verbose = @Verbose;
224+
225+
--Assert
226+
IF NOT EXISTS (SELECT 1 FROM #result WHERE [markdown] LIKE @Expected)
227+
EXEC tSQLt.Fail @FailMessage;
228+
END;
229+
230+
-- Succeed if version < 15
231+
EXEC tSQLt.ExpectNoException;
232+
233+
END;
234+
GO
235+
190236
/************************************
191237
End sp_doc tests
192238
*************************************/

0 commit comments

Comments
 (0)