generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ORV2-2543 Credit Account Granularity based on Roles (#1490)
- Loading branch information
Showing
11 changed files
with
339 additions
and
64 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
database/mssql/scripts/versions/revert/v_33_ddl_revert.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
SET ANSI_NULLS ON | ||
GO | ||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
SET NOCOUNT ON | ||
GO | ||
|
||
SET XACT_ABORT ON | ||
|
||
BEGIN TRY | ||
BEGIN TRANSACTION | ||
|
||
DELETE FROM [access].[ORBC_GROUP_ROLE] WHERE ROLE_TYPE ='ORBC-READ-CREDIT-ACCOUNT' AND USER_AUTH_GROUP_TYPE IN ('PPCCLERK', 'CTPO', 'HQADMIN') | ||
|
||
COMMIT | ||
END TRY | ||
|
||
BEGIN CATCH | ||
IF @@TRANCOUNT > 0 | ||
ROLLBACK; | ||
THROW | ||
END CATCH | ||
|
||
DECLARE @VersionDescription VARCHAR(255) | ||
SET @VersionDescription = 'Reverting mapping of ORBC-READ-CREDIT-ACCOUNT from PPCCLERK, CTPO, and HQADMIN.' | ||
|
||
INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (32, @VersionDescription, getutcdate()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
SET ANSI_NULLS ON | ||
GO | ||
|
||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
|
||
SET NOCOUNT ON | ||
GO | ||
|
||
SET XACT_ABORT ON | ||
GO | ||
|
||
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE | ||
GO | ||
|
||
BEGIN TRANSACTION | ||
GO | ||
|
||
IF @@ERROR <> 0 | ||
SET NOEXEC ON | ||
GO | ||
|
||
|
||
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'PPCCLERK', N'ORBC-READ-CREDIT-ACCOUNT') | ||
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'CTPO', N'ORBC-READ-CREDIT-ACCOUNT') | ||
INSERT [access].[ORBC_GROUP_ROLE] ([USER_AUTH_GROUP_TYPE], [ROLE_TYPE]) VALUES (N'HQADMIN', N'ORBC-READ-CREDIT-ACCOUNT') | ||
GO | ||
|
||
DECLARE @VersionDescription VARCHAR(255) | ||
SET @VersionDescription = 'Add ORBC-READ-CREDIT-ACCOUNT to PPCCLERK, CTPO, and HQADMIN' | ||
|
||
INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (33, @VersionDescription, '$(UPDATE_SCRIPT)', '$(REVERT_SCRIPT)', getutcdate()) | ||
IF @@ERROR <> 0 SET NOEXEC ON | ||
GO | ||
|
||
COMMIT TRANSACTION | ||
GO | ||
IF @@ERROR <> 0 SET NOEXEC ON | ||
GO | ||
DECLARE @Success AS BIT | ||
SET @Success = 1 | ||
SET NOEXEC OFF | ||
IF (@Success = 1) PRINT 'The database update succeeded' | ||
ELSE BEGIN | ||
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION | ||
PRINT 'The database update failed' | ||
END | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Test that the role types have been inserted correctly | ||
SET NOCOUNT ON | ||
|
||
SELECT COUNT(*) FROM $(DB_NAME).[access].[ORBC_ROLE_TYPE] | ||
WHERE ROLE_TYPE ='ORBC-READ-CREDIT-ACCOUNT' AND USER_AUTH_GROUP_TYPE IN ('PPCCLERK', 'CTPO', 'HQADMIN') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Retrieve arguments | ||
source ${SCRIPT_DIR}/utility/getopt.sh | ||
USAGE="-u USER -p PASS -s SERVER -d DATABASE" | ||
parse_options "${USAGE}" ${@} | ||
|
||
# All database tests for database version 33 are run from this shell script. | ||
# TESTS_DIR variable set by the calling test-runner script. | ||
|
||
TEST_33_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_33_1_test.sql | xargs) | ||
if [[ $TEST_33_1_RESULT -eq 3 ]]; then | ||
echo "Test 33.1 passed: Role types inserted correctly" | ||
else | ||
echo "******** Test 33.1 failed: Role types not inserted correctly" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Evaluates the given predicate and returns the value if the predicate is true or the value is not null, otherwise returns undefined. | ||
* | ||
* @param {T} value - The value to be returned if the predicate evaluates to true or the value is not null. | ||
* @param {() => boolean} [predicate] - An optional function that returns a boolean indicating whether the value should be substituted. | ||
* @returns {T | undefined} - The value if predicate evaluates to true or the value is not null, otherwise undefined. | ||
*/ | ||
export const undefinedSubstitution = <T>( | ||
value: T, | ||
predicate?: () => boolean, | ||
): T | undefined => { | ||
let result: T | undefined; | ||
|
||
if (predicate) { | ||
result = predicate() ? value : undefined; | ||
} else { | ||
result = value ?? undefined; | ||
} | ||
|
||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.