-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
91 additions
and
12 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
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
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
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,6 @@ | ||
--- | ||
services: | ||
github-mock: | ||
build: github-mock | ||
ports: | ||
- 4010:4010 |
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,29 @@ | ||
FROM debian:bookworm-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV PRISM_VERSION=v5.3.1 | ||
|
||
RUN curl https://github.com/stoplightio/prism/releases/download/${PRISM_VERSION}/prism-cli-linux \ | ||
-L \ | ||
-o /usr/local/bin/prism \ | ||
&& chmod +x /usr/local/bin/prism | ||
|
||
WORKDIR /app | ||
|
||
RUN curl -O -L https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/ghec/ghec.2022-11-28.json | ||
|
||
# There's a misconfiguration in the openapi file, we are going to replace the following strings: | ||
# - "server-statistics-actions.yaml" -> "#/components/schemas/server-statistics-actions" | ||
# - "server-statistics-packages.yaml" -> "#/components/schemas/server-statistics-packages" | ||
|
||
RUN sed -i 's/server-statistics-actions.yaml/#\/components\/schemas\/server-statistics-actions/g' ghec.2022-11-28.json \ | ||
&& sed -i 's/server-statistics-packages.yaml/#\/components\/schemas\/server-statistics-packages/g' ghec.2022-11-28.json | ||
|
||
ENTRYPOINT [ "prism" ] | ||
|
||
CMD ["mock", "ghec.2022-11-28.json", "-h", "0.0.0.0"] |
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,34 @@ | ||
from gettext import install | ||
from bert_e.git_host.github import Client | ||
from pytest import fixture | ||
from cryptography.hazmat.primitives import serialization as crypto_serialization | ||
from cryptography.hazmat.primitives.asymmetric import rsa | ||
from cryptography.hazmat.backends import default_backend as crypto_default_backend | ||
|
||
@fixture | ||
def client_app(): | ||
private_key = rsa.generate_private_key( | ||
public_exponent=65537, | ||
key_size=2048, | ||
backend=crypto_default_backend() | ||
) | ||
return Client( | ||
login='login', | ||
password='password', | ||
email='[email protected]', | ||
app_id=1, | ||
installation_id=1, | ||
private_key=private_key.private_bytes( | ||
crypto_serialization.Encoding.PEM, | ||
crypto_serialization.PrivateFormat.PKCS8, | ||
crypto_serialization.NoEncryption() | ||
), | ||
base_url="http://localhost:4010", | ||
accept_header="application/json" | ||
) | ||
|
||
def test_github_auth_app(client_app): | ||
repository = client_app.get_repository('octo-org', 'Hello-World') | ||
pr = repository.get_pull_request(1) | ||
assert pr.id == 1347 | ||
assert client_app.headers['Authorization'].startswith('Bearer ') == True |