|
| 1 | +@RHIdentity |
| 2 | +Feature: Authorized endpoint API tests for the rh-identity authentication module |
| 3 | + |
| 4 | + Background: |
| 5 | + Given The service is started locally |
| 6 | + And REST API service prefix is /v1 |
| 7 | + |
| 8 | + Scenario: Request fails when x-rh-identity header is missing |
| 9 | + Given The system is in default state |
| 10 | + When I access endpoint "authorized" using HTTP POST method |
| 11 | + """ |
| 12 | + {"placeholder":"abc"} |
| 13 | + """ |
| 14 | + Then The status code of the response is 401 |
| 15 | + And The body of the response is the following |
| 16 | + """ |
| 17 | + {"detail": "Missing x-rh-identity header"} |
| 18 | + """ |
| 19 | + |
| 20 | + Scenario: Request fails when identity field is missing |
| 21 | + Given The system is in default state |
| 22 | + And I set the x-rh-identity header with JSON |
| 23 | + """ |
| 24 | + {"entitlements": {"rhel": {"is_entitled": true}}} |
| 25 | + """ |
| 26 | + When I access endpoint "authorized" using HTTP POST method |
| 27 | + """ |
| 28 | + {"placeholder":"abc"} |
| 29 | + """ |
| 30 | + Then The status code of the response is 400 |
| 31 | + And The body of the response contains "Missing 'identity' field" |
| 32 | + |
| 33 | + Scenario: Request succeeds with valid User identity and required entitlements |
| 34 | + Given The system is in default state |
| 35 | + And I set the x-rh-identity header with valid User identity |
| 36 | + | field | value | |
| 37 | + | user_id | test-user-123 | |
| 38 | + | username | testuser@redhat.com | |
| 39 | + | org_id | 321 | |
| 40 | + | entitlements | rhel | |
| 41 | + When I access endpoint "authorized" using HTTP POST method |
| 42 | + """ |
| 43 | + {"placeholder":"abc"} |
| 44 | + """ |
| 45 | + Then The status code of the response is 200 |
| 46 | + And The body of the response is the following |
| 47 | + """ |
| 48 | + {"user_id": "test-user-123", "username": "testuser@redhat.com", "skip_userid_check": false} |
| 49 | + """ |
| 50 | + |
| 51 | + Scenario: Request succeeds with valid System identity and required entitlements |
| 52 | + Given The system is in default state |
| 53 | + And I set the x-rh-identity header with valid System identity |
| 54 | + | field | value | |
| 55 | + | cn | c87dcb4c-8af1-40dd-878e-60c744edddd0 | |
| 56 | + | account_number | 456 | |
| 57 | + | org_id | 654 | |
| 58 | + | entitlements | rhel | |
| 59 | + When I access endpoint "authorized" using HTTP POST method |
| 60 | + """ |
| 61 | + {"placeholder":"abc"} |
| 62 | + """ |
| 63 | + Then The status code of the response is 200 |
| 64 | + And The body of the response is the following |
| 65 | + """ |
| 66 | + {"user_id": "c87dcb4c-8af1-40dd-878e-60c744edddd0", "username": "456", "skip_userid_check": false} |
| 67 | + """ |
| 68 | + |
| 69 | + Scenario: Request fails when required entitlement is missing |
| 70 | + Given The system is in default state |
| 71 | + And I set the x-rh-identity header with valid User identity |
| 72 | + | field | value | |
| 73 | + | user_id | test-user-123 | |
| 74 | + | username | testuser@redhat.com | |
| 75 | + | org_id | 321 | |
| 76 | + | entitlements | ansible | |
| 77 | + When I access endpoint "authorized" using HTTP POST method |
| 78 | + """ |
| 79 | + {"placeholder":"abc"} |
| 80 | + """ |
| 81 | + Then The status code of the response is 403 |
| 82 | + And The body of the response contains "Missing required entitlement" |
| 83 | + |
| 84 | + Scenario: Request fails when entitlement exists but is_entitled is false |
| 85 | + Given The system is in default state |
| 86 | + And I set the x-rh-identity header with JSON |
| 87 | + """ |
| 88 | + { |
| 89 | + "identity": { |
| 90 | + "type": "User", |
| 91 | + "org_id": "321", |
| 92 | + "user": {"user_id": "test-user-123", "username": "testuser@redhat.com"} |
| 93 | + }, |
| 94 | + "entitlements": {"rhel": {"is_entitled": false, "is_trial": true}} |
| 95 | + } |
| 96 | + """ |
| 97 | + When I access endpoint "authorized" using HTTP POST method |
| 98 | + """ |
| 99 | + {"placeholder":"abc"} |
| 100 | + """ |
| 101 | + Then The status code of the response is 403 |
| 102 | + And The body of the response contains "Missing required entitlement" |
| 103 | + |
| 104 | + Scenario: Request fails when User identity is missing user_id |
| 105 | + Given The system is in default state |
| 106 | + And I set the x-rh-identity header with JSON |
| 107 | + """ |
| 108 | + { |
| 109 | + "identity": { |
| 110 | + "type": "User", |
| 111 | + "org_id": "321", |
| 112 | + "user": {"username": "testuser@redhat.com"} |
| 113 | + }, |
| 114 | + "entitlements": {"rhel": {"is_entitled": true}} |
| 115 | + } |
| 116 | + """ |
| 117 | + When I access endpoint "authorized" using HTTP POST method |
| 118 | + """ |
| 119 | + {"placeholder":"abc"} |
| 120 | + """ |
| 121 | + Then The status code of the response is 400 |
| 122 | + And The body of the response contains "Missing 'user_id' in user data" |
| 123 | + |
| 124 | + Scenario: Request fails when User identity is missing username |
| 125 | + Given The system is in default state |
| 126 | + And I set the x-rh-identity header with JSON |
| 127 | + """ |
| 128 | + { |
| 129 | + "identity": { |
| 130 | + "type": "User", |
| 131 | + "org_id": "321", |
| 132 | + "user": {"user_id": "test-user-123"} |
| 133 | + }, |
| 134 | + "entitlements": {"rhel": {"is_entitled": true}} |
| 135 | + } |
| 136 | + """ |
| 137 | + When I access endpoint "authorized" using HTTP POST method |
| 138 | + """ |
| 139 | + {"placeholder":"abc"} |
| 140 | + """ |
| 141 | + Then The status code of the response is 400 |
| 142 | + And The body of the response contains "Missing 'username' in user data" |
| 143 | + |
| 144 | + Scenario: Request fails when System identity is missing cn |
| 145 | + Given The system is in default state |
| 146 | + And I set the x-rh-identity header with JSON |
| 147 | + """ |
| 148 | + { |
| 149 | + "identity": { |
| 150 | + "type": "System", |
| 151 | + "account_number": "456", |
| 152 | + "org_id": "654", |
| 153 | + "system": {} |
| 154 | + }, |
| 155 | + "entitlements": {"rhel": {"is_entitled": true}} |
| 156 | + } |
| 157 | + """ |
| 158 | + When I access endpoint "authorized" using HTTP POST method |
| 159 | + """ |
| 160 | + {"placeholder":"abc"} |
| 161 | + """ |
| 162 | + Then The status code of the response is 400 |
| 163 | + And The body of the response contains "Missing 'cn' in system data" |
0 commit comments