Skip to content

Commit

Permalink
Merge pull request #5 from SURFscz/feature-behave
Browse files Browse the repository at this point in the history
Rewrite tests to behave features and scenarios
  • Loading branch information
baszoetekouw authored Nov 13, 2024
2 parents d65e2db + 7a1c1c3 commit c7c78c5
Show file tree
Hide file tree
Showing 12 changed files with 397 additions and 473 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pyvenv.cfg
config.yml
prd.yml
acc.yml
browser
./*.yml
status/
venv/
screenshot.png
178 changes: 107 additions & 71 deletions config.yml.example
Original file line number Diff line number Diff line change
@@ -1,104 +1,140 @@
sbs_ci:
start: 'https://changeit/landing'
user: 'changeit'
password: 'changeit'
---
sbs:
url: 'https://acc.sram.surf.nl/'

sram_monitoring:
'https://demo-sp.sram.surf.nl/rp/acc':
user1.password:
sub: [email protected]
name: Student One
eduperson_entitlement:
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:sram_demosp_acc-tweebob
- urn:mace:surf.nl:sram-acc:group:surf_demo
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:testdienst-g2
- urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org
voperson_external_affiliation:
- [email protected]
- [email protected]
user2.password:
sub: [email protected]
name: Employee One
pam:
token: 'xxx'

monitoring:
oidc_url: 'https://demo-sp.sram.surf.nl/rp/acc'
saml_url: 'https://demo-sp.sram.surf.nl/auth/acc?format=json'

accounts:
student:
name: 'Student One'
password: 'xxx'
employee:
name: 'Employee One'
password: 'xxx'

user_data:
student:
oidc_url:
sub: "[email protected]"
name: "Student One"
given_name: "Student"
family_name: "One"
email: "[email protected]"
uid:
- "sone"
eduperson_entitlement:
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:sram_demosp_acc-tweebob
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco
- urn:mace:surf.nl:sram-acc:group:surf_demo
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:testdienst-g2
- urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org
- "urn:mace:surf.nl:sram-acc:group:sramadmin:samloidc_monitor"
- "urn:mace:surf.nl:sram-acc:group:sramadmin"
- "urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org"
eduperson_principal_name:
- "[email protected]"
eduperson_scoped_affiliation:
- "[email protected]"
voperson_external_affiliation:
- [email protected]
- [email protected]
'https://demo-sp.sram.surf.nl/auth/acc?format=json':
user1.password:
- "[email protected]"
- "[email protected]"
voperson_external_id:
- "[email protected]"
voperson_id:
- "[email protected]"

saml_url:
uid:
- sone
- "sone"
schacHomeOrganization:
- test-idp.sram.surf.nl
- "test-idp.sram.surf.nl"
voPersonExternalID:
- [email protected]
- "[email protected]"
displayName:
- Student One
- "Student One"
cn:
- Student One
- "Student One"
sn:
- One
- "One"
givenName:
- Student
- "Student"
mail:
- [email protected]
- "[email protected]"
eduPersonUniqueId:
- [email protected]
- "[email protected]"
subject-id:
- [email protected]
- "[email protected]"
voPersonID:
- [email protected]
- "[email protected]"
voPersonExternalAffiliation:
- [email protected]
- [email protected]
- "[email protected]"
- "[email protected]"
eduPersonEntitlement:
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:sram_demosp_acc-tweebob
- urn:mace:surf.nl:sram-acc:group:surf_demo
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:testdienst-g2
- urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org
- "urn:mace:surf.nl:sram-acc:group:sramadmin"
- "urn:mace:surf.nl:sram-acc:group:sramadmin:samloidc_monitor"
- "urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org"
eduPersonPrincipalName:
- [email protected]
- "[email protected]"
eduPersonScopedAffiliation:
- [email protected]
user2.password:
- "[email protected]"

employee:
oidc_url:
sub: "[email protected]"
name: "Employee One"
given_name: "Employee"
family_name: "One"
email: "[email protected]"
uid:
- "eone"
eduperson_entitlement:
- "urn:mace:surf.nl:sram-acc:group:sramadmin"
- "urn:mace:surf.nl:sram-acc:group:sramadmin:samloidc_monitor"
- "urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org"
eduperson_principal_name:
- "[email protected]"
eduperson_scoped_affiliation:
- "[email protected]"
voperson_external_affiliation:
- "[email protected]"
- "[email protected]"
voperson_external_id:
- "[email protected]"
voperson_id:
- "[email protected]"

saml_url:
uid:
- eone
- "eone"
schacHomeOrganization:
- test-idp.sram.surf.nl
- "test-idp.sram.surf.nl"
voPersonExternalID:
- [email protected]
- "[email protected]"
displayName:
- Employee One
- "Employee One"
cn:
- Employee One
- "Employee One"
sn:
- One
- "One"
givenName:
- Employee
- "Employee"
mail:
- [email protected]
- "[email protected]"
eduPersonUniqueId:
- [email protected]
- "[email protected]"
subject-id:
- [email protected]
- "[email protected]"
voPersonID:
- [email protected]
- "[email protected]"
voPersonExternalAffiliation:
- [email protected]
- [email protected]
- "[email protected]"
- "[email protected]"
eduPersonEntitlement:
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:testdienst-g2
- urn:mace:surf.nl:sram-acc:group:surf_demo
- urn:mace:surf.nl:sram-acc:group:surf_demo:monitoringco:sram_demosp_acc-tweebob
- urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org
- "urn:mace:surf.nl:sram-acc:group:sramadmin"
- "urn:mace:surf.nl:sram-acc:group:sramadmin:samloidc_monitor"
- "urn:geant:eduteams.org:acc.sram.eduteams.org:group:surf-ram#acc.sram.eduteams.org"
eduPersonPrincipalName:
- [email protected]
- "[email protected]"
eduPersonScopedAffiliation:
- [email protected]
- "[email protected]"

14 changes: 14 additions & 0 deletions features/01_monitoring.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Monitoring
Scenario Outline: Verifying End-to-End flow for user <user>
Given SBS health UP
and we visit monitoring <start>
and we choose SRAM Monitoring IdP
When we login as <user>
Then test userdata for <user> in <start>

Examples: Test
| start | user |
| oidc_url | student |
| saml_url | student |
| oidc_url | employee |
| saml_url | employee |
12 changes: 12 additions & 0 deletions features/02_sbs.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: SBS login
Scenario Outline: Verifying SBS login user <user>
Given SBS health UP
and we visit profile
and we choose SRAM Monitoring IdP
When we login as <user>
Then <user> name in profile

Examples: Test
| user |
| student |
| employee |
12 changes: 12 additions & 0 deletions features/03_pam-weblogin.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: PAM weblogin
Scenario Outline: Verifying PAM weblogin for user <user>
Given SBS health UP
and we call pam start
and we use link to login
and we choose SRAM Monitoring IdP
When we login as <user>
Then we use code to check pam check-pin

Examples: Test
| user |
| student |
57 changes: 57 additions & 0 deletions features/environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from behave import fixture, use_fixture
from selenium.webdriver import Remote, ChromeOptions, FirefoxOptions
from selenium.webdriver.support.wait import WebDriverWait
import yaml


@fixture
def selenium_browser(context, browser):
if browser == 'chrome':
options = ChromeOptions()
else:
options = FirefoxOptions()

options.add_argument('--headless')
# options.add_argument('--ignore-certificate-errors')
# options.add_argument('--user-data-dir=/tmp/chrome-data')
context.browser = Remote("http://127.0.0.1:4444", options=options)
context.browser.implicitly_wait(5)
context.wait = WebDriverWait(context.browser, timeout=5)

# Halts all tests on error
context.config.stop = True
yield context.browser

context.browser.quit()


def before_all(context):
env = context.config.userdata.get("ENV")

with open(env, 'r') as f:
try:
config = yaml.load(f, Loader=yaml.FullLoader)
except yaml.YAMLError as exc:
print(exc)

context.env = config


def before_feature(context, feature):
pass


def before_scenario(context, scenario):
browser = context.config.userdata.get("BROWSER")
use_fixture(selenium_browser, context, browser)


def after_scenario(context, scenario):
pass


def after_step(context, step):
if step.status == "failed":
print(context.browser.current_url)
print(context.browser.page_source)
context.browser.save_screenshot("screenshot.png")
Loading

0 comments on commit c7c78c5

Please sign in to comment.