Playwright Tests / test (push) Canceled after 0s
- Added a new SQL script to address the "String or binary data would be truncated" error in mfr sync by widening the Note fields in service objects and companies to NVARCHAR(MAX). - Updated the table types and associated stored procedures to accommodate the changes, ensuring compatibility with existing data. - Queued a re-sync for previously rejected rows due to truncation issues. - Created application logins for fuchs_fds and fuchs_web with placeholder passwords for initial setup. - Introduced functions for invoice backdating and invoice date retrieval to streamline invoice processing. - Developed a password generation function with customizable parameters for length and character types. - Added a random number generation function to support password creation.
88 lines
3.4 KiB
Transact-SQL
88 lines
3.4 KiB
Transact-SQL
|
|
|
|
CREATE FUNCTION [dbo].[ocms_fn_generatePassword] (
|
|
@length int
|
|
, @specialChars bit = 1
|
|
, @nums bit = 1
|
|
, @lowerCase bit = 1
|
|
)
|
|
RETURNS varchar(255)
|
|
AS
|
|
BEGIN
|
|
DECLARE @randInt int;
|
|
DECLARE @NewCharacter varchar(1);
|
|
DECLARE @NewPassword TABLE([typ] char(1), [char] char(1), [order] int);
|
|
|
|
SET @length = CASE WHEN @length > 255 THEN 255 ELSE @length END;
|
|
|
|
DECLARE @cnt int = 0, @position as int;
|
|
--random characters
|
|
WHILE (@cnt < @length)
|
|
BEGIN
|
|
SELECT @randInt = [dbo].[ocms_fn_randbetween](33,122)
|
|
|
|
IF (CASE WHEN (@randInt>=33 AND @randInt<=47) AND @specialChars = 1 THEN 1
|
|
WHEN (@randInt>=48 AND @randInt<=57) AND @nums = 1 THEN 1
|
|
WHEN (@randInt>=58 AND @randInt<=64) AND @specialChars = 1 THEN 1
|
|
WHEN (@randInt>=65 AND @randInt<=90) THEN 1
|
|
WHEN (@randInt>=91 AND @randInt<=93) AND @specialChars = 1 THEN 1
|
|
WHEN (@randInt>=97 AND @randInt<=122) AND @lowerCase = 1 THEN 1
|
|
ELSE 0
|
|
END) = 1
|
|
BEGIN
|
|
SET @cnt = @cnt + 1;
|
|
|
|
INSERT INTO @NewPassword
|
|
VALUES (CASE WHEN (@randInt>=33 AND @randInt<=47) THEN 's'
|
|
WHEN (@randInt>=48 AND @randInt<=57) THEN 'n'
|
|
WHEN (@randInt>=58 AND @randInt<=64) THEN 's'
|
|
WHEN (@randInt>=65 AND @randInt<=90) THEN 'u'
|
|
WHEN (@randInt>=91 AND @randInt<=93) THEN 's'
|
|
WHEN (@randInt>=97 AND @randInt<=122) THEN 'l'
|
|
END,
|
|
CHAR(@randInt), @cnt);
|
|
END
|
|
END
|
|
|
|
DECLARE @min_n int = CASE WHEN @length > 4 AND @length < 11 THEN 1 ELSE FLOOR(@length * 0.1) END;
|
|
DECLARE @min_s int = FLOOR(@length * 0.1);
|
|
DECLARE @min_l int = FLOOR(@length * 0.4);
|
|
DECLARE @min_u int = FLOOR(@length * 0.4);
|
|
|
|
WHILE (SELECT COUNT(*) FROM @NewPassword WHERE [typ] = 'n') < @min_n AND @length > 0 AND @nums = 1
|
|
BEGIN
|
|
SET @position = [dbo].[ocms_fn_randbetween](1,@length);
|
|
UPDATE @NewPassword SET [char] = CHAR([dbo].[ocms_fn_randbetween](48,57)), [typ] = 'n' WHERE [order] = @position;
|
|
END
|
|
|
|
WHILE (SELECT COUNT(*) FROM @NewPassword WHERE [typ] = 'l') < @min_l AND @length > 0 AND @lowerCase = 1
|
|
BEGIN
|
|
SET @position = [dbo].[ocms_fn_randbetween](1,@length);
|
|
UPDATE @NewPassword SET [char] = CHAR([dbo].[ocms_fn_randbetween](97,122)), [typ] = 'l' WHERE [order] = @position;
|
|
END
|
|
|
|
WHILE (SELECT COUNT(*) FROM @NewPassword WHERE [typ] = 'u') < @min_n AND @length > 0
|
|
BEGIN
|
|
SET @position = [dbo].[ocms_fn_randbetween](1,@length);
|
|
UPDATE @NewPassword SET [char] = CHAR([dbo].[ocms_fn_randbetween](65,90)), [typ] = 'u' WHERE [order] = @position;
|
|
END
|
|
|
|
WHILE (SELECT COUNT(*) FROM @NewPassword WHERE [typ] = 's') < @min_s AND @length > 0 AND @specialChars = 1
|
|
BEGIN
|
|
SET @position = [dbo].[ocms_fn_randbetween](1,@length);
|
|
DECLARE @nc char(1), @nt char(1);
|
|
select @randInt=[dbo].[ocms_fn_randbetween](33,122)
|
|
|
|
UPDATE @NewPassword SET [char] = CHAR(@randint), [typ] = 's' WHERE [order] = @position AND (CASE WHEN (@randInt>=33 AND @randInt<=47) THEN 's'
|
|
WHEN (@randInt>=48 AND @randInt<=57) THEN 'n'
|
|
WHEN (@randInt>=58 AND @randInt<=64) THEN 's'
|
|
WHEN (@randInt>=65 AND @randInt<=90) THEN 'u'
|
|
WHEN (@randInt>=91 AND @randInt<=93) THEN 's'
|
|
WHEN (@randInt>=97 AND @randInt<=122) THEN 'l'
|
|
END) = 's';
|
|
END
|
|
|
|
|
|
|
|
RETURN (Cast((SELECT [CHAR] as [text()] FROM @NewPassword FOR XML PATH(''),TYPE).value('.','NVARCHAR(MAX)') as varchar(255)));
|
|
END; |