This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
generated from agilepathway/agilepathway-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Specify internal employee project visibility #29
Open
johnboyes
wants to merge
6
commits into
master
Choose a base branch
from
project-visibility
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
234d0ee
Specify internal employee project visibility
johnboyes 2c91a57
Extract Jira class
johnboyes e9ae516
Extract bot class
johnboyes c834603
Refactor group membership method
johnboyes 1210311
Refactor all env vars into Bot file
johnboyes deae730
Update contributing guidelines
johnboyes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,14 +24,25 @@ jobs: | |
with: | ||
python-version: 3.8.6 | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
|
||
- name: Install Gauge | ||
uses: getgauge/setup-gauge@master | ||
with: | ||
gauge-version: master | ||
gauge-plugins: python, html-report | ||
gauge-plugins: python, html-report, screenshot | ||
|
||
- name: FTs | ||
run: gauge run specs | ||
env: | ||
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} | ||
JIRA_ADMIN_USERNAME: ${{ secrets.JIRA_ADMIN_USERNAME }} | ||
JIRA_ADMIN_PASSWORD: ${{ secrets.JIRA_ADMIN_PASSWORD }} | ||
INTERNAL_EMPLOYEE_USERNAME: ${{ secrets.INTERNAL_EMPLOYEE_USERNAME }} | ||
INTERNAL_EMPLOYEE_PASSWORD: ${{ secrets.INTERNAL_EMPLOYEE_PASSWORD }} | ||
run: gauge run specs --tags \!in-progress | ||
|
||
- name: Upload logs | ||
uses: actions/[email protected] | ||
|
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
getgauge | ||
jira |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
# Group membership | ||
|
||
Our implementation of group membership rules is based on | ||
https://www.atlassian.com/blog/archives/share-jira-external-partners | ||
|
||
## All employees are members of the internal employees group | ||
|
||
* An internal employee is a member of the internal employees group |
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,10 @@ | ||
# Groups | ||
|
||
Our groups are based on the ideas in | ||
https://www.atlassian.com/blog/archives/share-jira-external-partners | ||
|
||
## There is an internal employees group | ||
|
||
This group is for all internal employees who currently need access to this Jira instance | ||
|
||
* There is a jira-internal-employee-users group |
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,25 @@ | ||
# Project visibility | ||
|
||
Our implementation of project visibility rules is based on | ||
https://www.atlassian.com/blog/archives/share-jira-external-partners | ||
|
||
## All internal employees can see all projects | ||
|
||
This is in line with our [InnerSource](https://about.gitlab.com/solutions/innersource/) principles. | ||
|
||
* An internal employee can see all projects | ||
|
||
## All external partners can only see the projects they are currently working on | ||
|
||
tags: in-progress | ||
|
||
Question: what about individual contractors, as opposed to external partner companies? | ||
|
||
* Not implemented yet | ||
|
||
## Closed projects are no longer viewable by any external partners | ||
|
||
tags: in-progress | ||
|
||
* Not implemented yet | ||
|
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 @@ | ||
from getgauge.python import before_suite | ||
from jira import JIRA | ||
import os | ||
|
||
|
||
class Jira: | ||
def __init__(self, username, password): | ||
self.jira = JIRA( | ||
auth=(username, password), | ||
options={"server": os.getenv("JIRA_BASE_URL")}, | ||
) | ||
|
||
def has_group(self, group_name): | ||
return len(self.jira.group_members(group_name)) >= 0 | ||
|
||
def projects(self): | ||
return self.jira.projects() | ||
|
||
def is_internal_employee_in_internal_employees_group(self): | ||
internal_employees = self.jira.group_members("jira-internal-employee_users") | ||
return bool( | ||
[ | ||
emp | ||
for emp in internal_employees.values() | ||
if (emp["name"] == os.getenv("INTERNAL_EMPLOYEE_USERNAME")) | ||
] | ||
) |
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 |
---|---|---|
@@ -1,45 +1,33 @@ | ||
from getgauge.python import step, before_scenario, Messages | ||
from getgauge.python import step | ||
from step_impl.jira import Jira | ||
import os | ||
|
||
vowels = ["a", "e", "i", "o", "u"] | ||
|
||
def jira_admin(): | ||
return Jira(os.getenv("JIRA_ADMIN_USERNAME"), os.getenv("JIRA_ADMIN_PASSWORD")) | ||
|
||
def number_of_vowels(word): | ||
return len([elem for elem in list(word) if elem in vowels]) | ||
|
||
def internal_employee(): | ||
return Jira( | ||
os.getenv("INTERNAL_EMPLOYEE_USERNAME"), os.getenv("INTERNAL_EMPLOYEE_PASSWORD") | ||
) | ||
|
||
# -------------------------- | ||
# Gauge step implementations | ||
# -------------------------- | ||
|
||
@step("An internal employee can see all projects") | ||
def an_internal_employee_can_see_all_projects(): | ||
assert len(jira_admin().projects()) == len(internal_employee().projects()) | ||
|
||
@step("The word <word> has <number> vowels.") | ||
def assert_no_of_vowels_in(word, number): | ||
assert str(number) == str(number_of_vowels(word)) | ||
|
||
@step("An internal employee is a member of the internal employees group") | ||
def an_internal_employee_is_a_member_of_the_internal_employees_group(): | ||
assert jira_admin().is_internal_employee_in_internal_employees_group() | ||
|
||
@step("Vowels in English language are <vowels>.") | ||
def assert_default_vowels(given_vowels): | ||
Messages.write_message("Given vowels are {0}".format(given_vowels)) | ||
assert given_vowels == "".join(vowels) | ||
|
||
@step("There is a jira-internal-employee-users group") | ||
def there_is_a_jira_internal_employee_users_group(): | ||
assert jira_admin().has_group("jira-internal-employee_users") | ||
|
||
@step("Almost all words have vowels <table>") | ||
def assert_words_vowel_count(table): | ||
actual = [ | ||
str(number_of_vowels(word)) | ||
for word in table.get_column_values_with_name("Word") | ||
] | ||
expected = [ | ||
str(count) for count in table.get_column_values_with_name("Vowel Count") | ||
] | ||
assert expected == actual | ||
|
||
|
||
# --------------- | ||
# Execution Hooks | ||
# --------------- | ||
|
||
|
||
@before_scenario() | ||
def before_scenario_hook(): | ||
assert "".join(vowels) == "aeiou" | ||
@step("Not implemented yet") | ||
def not_implemented_yet(): | ||
assert False, "Add implementation code" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there are a lot of layers in the python module and in the Jira logic over which we don't have control and if they change the simple checking of the same number of projects may lead to false positives. It might be safer to check if they can see the same number projects and if their project id's match: