8000 Cherry-Pick Skill Validation to 4.7 (#1375) (#1379) · mmtrucefacts/botbuilder-python@5b53dd5 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 5b53dd5

Browse files
Cherry-Pick Skill Validation to 4.7 (microsoft#1375) (microsoft#1379)
* Throw if is_skill_claim and claims_validator is null (microsoft#1375)dd Skill Validation * Throw if is_skill_claim and claims_validator is null * Update jwt_token_validation.py * Adding yml pipeline * black compliant Co-authored-by: Axel Suarez <axsuarez@microsoft.com>
1 parent 0fd5a13 commit 5b53dd5

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

libraries/botframework-connector/botframework/connector/auth/jwt_token_validation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ async def validate_claims(
165165
):
166166
if auth_config and auth_config.claims_validator:
167167
await auth_config.claims_validator(claims)
168+
elif SkillValidation.is_skill_claim(claims):
169+
# Skill claims must be validated using AuthenticationConfiguration claims_validator.
170+
raise PermissionError(
171+
"Unauthorized Access. Request is not authorized. Skill Claims require validation."
172+
)
168173

169174
@staticmethod
170175
def is_government(channel_service: str) -> bool:

pipelines/botbuilder-python-ci.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
variables:
2+
# Container registry service connection established during pipeline creation
3+
CI_PULL_REQUEST: $(System.PullRequest.PullRequestId)
4+
COVERALLS_FLAG_NAME: Build \# $(Build.BuildNumber)
5+
COVERALLS_GIT_BRANCH: $(Build.SourceBranchName)
6+
COVERALLS_GIT_COMMIT: $(Build.SourceVersion)
10000 7+
COVERALLS_SERVICE_JOB_ID: $(Build.BuildId)
8+
COVERALLS_SERVICE_NAME: python-ci
9+
python.36: 3.6.x
10+
python.37: 3.7.x
11+
python.38: 3.8.x
12+
# PythonCoverallsToken: get this from Azure
13+
14+
jobs:
15+
# Build and publish container
16+
- job: Build
17+
#Multi-configuration and multi-agent job options are not exported to YAML. Configure these options using documentation guidance: https://docs.microsoft.com/vsts/pipelines/process/phases
18+
pool:
19+
name: Hosted Ubuntu 1604
20+
21+
strategy:
22+
matrix:
23+
Python36:
24+
PYTHON_VERSION: '$(python.36)'
25+
Python37:
26+
PYTHON_VERSION: '$(python.37)'
27+
Python38:
28+
PYTHON_VERSION: '$(python.38)'
29+
maxParallel: 3
30+
31+
steps:
32+
- powershell: |
33+
Get-ChildItem env:* | sort-object name | Format-Table -Autosize -Wrap | Out-String -Width 120
34+
displayName: 'Get environment vars'
35+
36+
- task: UsePythonVersion@0
37+
displayName: 'Use Python $(PYTHON_VERSION)'
38+
inputs:
39+
versionSpec: '$(PYTHON_VERSION)'
40+
41+
- script: 'sudo ln -s /opt/hostedtoolcache/Python/3.6.9/x64/lib/libpython3.6m.so.1.0 /usr/lib/libpython3.6m.so'
42+
displayName: libpython3.6m
43+
44+
- script: |
45+
python -m pip install --upgrade pip
46+
pip install -e ./libraries/botbuilder-schema
47+
pip install -e ./libraries/botframework-connector
48+
pip install -e ./libraries/botbuilder-core
49+
pip install -e ./libraries/botbuilder-ai
50+
pip install -e ./libraries/botbuilder-applicationinsights
51+
pip install -e ./libraries/botbuilder-dialogs
52+
pip install -e ./libraries/botbuilder-azure
53+
pip install -e ./libraries/botbuilder-testing
54+
pip install -r ./libraries/botframework-connector/tests/requirements.txt
55+
pip install -r ./libraries/botbuilder-core/tests/requirements.txt
56+
pip install coveralls
57+
pip install pylint==2.4.4
58+
pip install black==19.10b0
59+
displayName: 'Install dependencies'
60+
61+
- script: |
62+
pip install pytest
63+
pip install pytest-cov
64+
pip install coveralls
65+
pytest --junitxml=junit/test-results.$(PYTHON_VERSION).xml --cov-config=.coveragerc --cov --cov-report=xml --cov-report=html
66+
displayName: Pytest
67+
68+
- task: PublishCodeCoverageResults@1
69+
displayName: 'Publish Test Coverage'
70+
inputs:
71+
codeCoverageTool: Cobertura
72+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
73+
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'
74+
75+
- task: PublishTestResults@2
76+
displayName: 'Publish Test Results **/test-results.$(PYTHON_VERSION).xml'
77+
inputs:
78+
testResultsFiles: '**/test-results.$(PYTHON_VERSION).xml'
79+
testRunTitle: 'Python $(PYTHON_VERSION)'
80+
81+
- script: 'black --check libraries'
82+
displayName: 'Check Black compliant'
83+
84+
- script: 'pylint --rcfile=.pylintrc libraries'
85+
displayName: Pylint
86+
87+
- script: 'COVERALLS_REPO_TOKEN=$(PythonCoverallsToken) coveralls'
88+
displayName: 'Push test results to coveralls https://coveralls.io/github/microsoft/botbuilder-python'
89+
continueOnError: true
90+
91+
- powershell: |
92+
Set-Location ..
93+
Get-ChildItem -Recurse -Force
94+
95+
displayName: 'Dir workspace'
96+
condition: succeededOrFailed()
97+
98+
- powershell: |
99+
# This task copies the code coverage file created by dotnet test into a well known location. In all
100+
# checks I've done, dotnet test ALWAYS outputs the coverage file to the temp directory.
101+
# My attempts to override this and have it go directly to the CodeCoverage directory have
102+
# all failed, so I'm just doing the copy here. (cmullins)
103+
104+
Get-ChildItem -Path "$(Build.SourcesDirectory)" -Include "*coverage*" | Copy-Item -Destination "$(Build.ArtifactStagingDirectory)/CodeCoverage"
105+
displayName: 'Copy .coverage Files to CodeCoverage folder'
106+
continueOnError: true

0 commit comments

Comments
 (0)
0