-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ranger REST API SmokeTests with ROBOT Framework
- Loading branch information
Abhishek Kumar
committed
Nov 22, 2024
1 parent
f06d0e7
commit 3790cc1
Showing
5 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
dev-support/smoketests/ranger/apis/policy_management.robot
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,54 @@ | ||
*** Settings *** | ||
Library Collections | ||
Resource resources.robot | ||
Suite Setup Initialize Ranger Session (HTTP) | ||
|
||
*** Variables *** | ||
${POLICY_NAME} hbase-archive | ||
${HDFS_SVC_NAME} dev_hdfs | ||
${HIVE_SVC_NAME} dev_hive | ||
${HIVE_POLICY} test policy | ||
${QPARAMS} servicename=dev_hive&policyname=test policy | ||
@{TEST_DB} test_db | ||
@{TEST_TABLE} test_tbl | ||
@{TEST_COL} * | ||
&{ACCESS_CR} type=create isAllowed=${true} | ||
&{ACCESS_AL} type=alter isAllowed=${true} | ||
&{ACCESS_DR} type=drop isAllowed=${true} | ||
@{ACCESSES} ${ACCESS_CR} ${ACCESS_AL} | ||
@{D_ACCESSES} ${ACCESS_DR} | ||
@{USERS} admin | ||
|
||
*** Test Cases *** | ||
Get All Policies | ||
${response}= GET On Session ranger /service/public/v2/api/policy | ||
Should Be Equal As Numbers ${response.status_code} 200 | ||
Log ${response.json()} | ||
|
||
|
||
Create New Hive Policy | ||
${database} Create Dictionary values=${TEST_DB} isExcludes=${false} isRecursive=${false} | ||
${table} Create Dictionary values=${TEST_TABLE} isExcludes=${false} isRecursive=${false} | ||
${column} Create Dictionary values=${TEST_COL} isExcludes=${false} isRecursive=${false} | ||
|
||
${resources} Create Dictionary database=${database} table=${table} column=${column} | ||
|
||
${policy_item} Create Dictionary delegateAdmin=${false} users=${USERS} accesses=${ACCESSES} | ||
${deny_policy_item} Create Dictionary delegateAdmin=${false} users=${USERS} accesses=${D_ACCESSES} | ||
|
||
${policy_items} Create List ${policy_item} | ||
${deny_policy_items} Create List ${deny_policy_item} | ||
${payload} Create Dictionary service=${HIVE_SVC_NAME} isEnabled=${true} isDenyAllElse=${false} name=test policy resources=${resources} policyItems=${policy_items} denyPolicyItems=${deny_policy_items} | ||
|
||
# Log and Verify Payload | ||
Log ${payload} | ||
|
||
${response}= POST On Session ranger /service/public/v2/api/policy json=${payload} | ||
Should Be Equal As Numbers ${response.status_code} 200 | ||
Log ${response.json()} | ||
|
||
|
||
Delete Hive Policy | ||
${response}= DELETE On Session ranger /service/public/v2/api/policy params=${QPARAMS} | ||
Should Be Equal As Numbers ${response.status_code} 204 | ||
|
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,12 @@ | ||
*** Settings *** | ||
Library RequestsLibrary | ||
|
||
*** Variables *** | ||
${RANGER_HOST} localhost | ||
${PORT} 6080 | ||
@{CREDS} admin rangerR0cks! | ||
|
||
*** Keywords *** | ||
Initialize Ranger Session (HTTP) | ||
Create Session ranger http://${RANGER_HOST}:${PORT} auth=${CREDS} | ||
|
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,8 @@ | ||
*** Settings *** | ||
Resource resources.robot | ||
|
||
*** Test Cases *** | ||
Create Ranger Session | ||
[Documentation] Establish a session with Ranger Admin | ||
Initialize Ranger Session (HTTP) | ||
|
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,12 @@ | ||
*** Settings *** | ||
Resource resources.robot | ||
Suite Setup Initialize Ranger Session (HTTP) | ||
|
||
*** Variables *** | ||
|
||
*** Test Cases *** | ||
Get All Users | ||
${response}= GET On Session ranger /service/xusers/users | ||
Should Be Equal As Numbers ${response.status_code} 200 | ||
Log ${response.json()} | ||
|