Skip to content

Commit 82f9935

Browse files
Merge pull request #4870 from linuxfoundation/unicron-v2-test-coverage-api-fixes-and-dev-claims
Unicron v2 test coverage api fixes and dev claims
2 parents 1ab6d25 + 451d94e commit 82f9935

File tree

10 files changed

+116
-19
lines changed

10 files changed

+116
-19
lines changed

.github/copilot-instructions.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# GitHub Copilot Project Instructions
2+
3+
You are assisting in this repository. The following rules are **mandatory** and override any defaults.
4+
5+
---
6+
7+
## General Behavior
8+
9+
1. **Read full files, not fragments**
10+
11+
- When you open a file, always consider the **entire file** contents, not just the visible or edited region.
12+
- Before refactoring or implementing features, scan all relevant files fully (including related modules) to understand existing patterns, types, and architecture.
13+
- Do not assume behavior from partial context if you can open and read the whole file instead.
14+
- Read files from other GitHub repositories as needed.
15+
- Read issues/pull requests from remote repositories as needed.
16+
17+
2. **No artificial time/phasing limits**
18+
19+
- Do **not** shorten work or split it into artificial “phases” just to finish quickly.
20+
- Always attempt to provide the **most complete, fully implemented solution** you reasonably can in a single pass:
21+
- Implement full feature logic instead of stubs.
22+
- Add tests when appropriate.
23+
- Update related documentation/configs only if clearly required.
24+
- Avoid responses like “I’ll do the rest later” or “this is just a partial implementation” unless explicitly requested.
25+
26+
3. **Never leave partially implemented code**
27+
28+
- Do **not** leave functions, classes, or modules partially implemented.
29+
- Always provide a complete implementation for any code you modify or add.
30+
- If you cannot fully implement something due to missing context, dependencies, or constraints, clearly state what is missing and provide a best-effort implementation based on available information.
31+
- In such cases ask for missing context and wait for my response before proceeding further.
32+
33+
---
34+
35+
## Testing & Validation
36+
37+
5. **Always test changes**
38+
39+
- Whenever you modify code, **run tests** relevant to the change to ensure correctness.
40+
- If you add or update tests:
41+
- Execute the new or modified tests to confirm they pass.
42+
- Ensure coverage reflects the newly added logic.
43+
- When presenting results:
44+
- Output plain test results or shell-style logs.
45+
- **Do not generate fancy Markdown summaries**, reports, tables, or “change overview” documents. outputting this in console is OK.
46+
- A simple textual summary or shell-like output is sufficient (e.g., which tests passed/failed).
47+
48+
---
49+
50+
## Git / Commits
51+
52+
3. **Do NOT generate commits**
53+
54+
- Never run Git commands that create commits, amend commits, or push changes.
55+
- Do **not** auto-generate commit messages or suggest commands like:
56+
- `git commit ...`
57+
- `git commit -m "..."`
58+
- `git commit --amend`
59+
- `git push`
60+
- I will create commits myself; they must be signed (`-S`) and signed-off (`-s`), so leave all commit creation to me.
61+
62+
- It is acceptable to:
63+
- Modify files in the working tree.
64+
- Describe *what* should be committed, but not *how* to commit.
65+
66+
---
67+
68+
## File / Directory Access
69+
70+
4. **Repository file access and permissions**
71+
72+
- You may read any file and directory within this repository and other repositories as needed.
73+
- **Never ask for additional read permissions** for items inside this repo; assume full access.
74+
- Locate relevant code by searching the repo, exploring related modules, tests, and configs. Fetch data from remote if needed.
75+
- If something is outside this repository entirely, its also OK to read it.
76+
77+
---
78+
79+
## Style of Assistance
80+
81+
- Follow the repository’s existing style, patterns, conventions, and architecture.
82+
- Avoid unnecessary churn or unrelated refactoring.
83+
- Explain non-obvious design decisions briefly in comments when helpful.
84+
- When uncertain, produce a **best-effort, concrete implementation** using the available code rather than asking unnecessary questions.
85+

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,7 @@ body.json
262262

263263
cla-backend-go/signatures_timestamp_backfill
264264
cla-backend-go/backfill-fallback-commands-cla*.sh
265+
cla-backend/python-api.log
266+
cla-backend/python-api.err
267+
cla-backend-go/golang-api.err
268+
cla-backend-go/golang-api.log

cla-backend/cla/auth.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
import cla
1313

14-
# LG: for local environment override
15-
# os.environ["AUTH0_USERNAME_CLAIM"] = os.getenv("AUTH0_USERNAME_CLAIM_CLI", os.environ["AUTH0_USERNAME_CLAIM"])
16-
1714
auth0_base_url = os.environ.get('AUTH0_DOMAIN', '')
1815
auth0_username_claim = os.environ.get('AUTH0_USERNAME_CLAIM', '')
1916
algorithms = [os.environ.get('AUTH0_ALGORITHM', '')]
@@ -123,9 +120,16 @@ def authenticate_user(headers):
123120

124121
username = payload.get(auth0_username_claim)
125122
if username is None:
126-
# LG: to have more info
127-
# raise AuthError(f"username not found in {auth0_username_claim}")
128-
raise AuthError('username claim not found')
123+
alt_claim = os.environ.get('AUTH0_USERNAME_CLAIM_CLI', '')
124+
if alt_claim != '':
125+
cla.log.warning(f"username claim not found in {auth0_username_claim}, trying {alt_claim}")
126+
username = payload.get(alt_claim)
127+
if username is None:
128+
cla.log.error(f"username claim not found in alternate source {alt_claim}")
129+
raise AuthError('username claim not found')
130+
else:
131+
cla.log.error(f"username claim not found in {auth0_username_claim}")
132+
raise AuthError('username claim not found')
129133

130134
auth_user = AuthUser(payload)
131135

cla-backend/cla/controllers/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def get_project_companies(project_id):
338338
company_ids = list(set([signature.get_signature_reference_id() for signature in signatures]))
339339
company = Company()
340340
all_companies = [comp.to_dict() for comp in company.all(company_ids)]
341-
all_companies = sorted(all_companies, key=lambda i: i['company_name'].casefold())
341+
all_companies = sorted(all_companies, key=lambda i: (i.get('company_name') or '').casefold())
342342

343343
return all_companies
344344

cla-backend/cla/models/github_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def oauth2_redirect(self, state, code, request): # pylint: disable=too-many-arg
354354
# Eventually handle user-from-session API callback
355355
try:
356356
state_data = json.loads(base64.urlsafe_b64decode(state.encode()).decode())
357-
except (ValueError, json.JSONDecodeError, binascii.Error):
357+
except (ValueError, json.JSONDecodeError, binascii.Error) as err:
358358
cla.log.warning(f"{fn} - failed to decode state: {state}, error: {err}")
359359
raise falcon.HTTPBadRequest("Invalid OAuth2 state", state)
360360
state_token = state_data["csrf"]

cla-backend/cla/routes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ def check_and_prepare_employee_signature(
13561356
"/signed/individual/{installation_id}/{github_repository_id}/{change_request_id}", versions=2,
13571357
)
13581358
def post_individual_signed(
1359-
body,
1359+
request,
13601360
installation_id: hug.types.number,
13611361
github_repository_id: hug.types.number,
13621362
change_request_id: hug.types.number,
@@ -1369,7 +1369,7 @@ def post_individual_signed(
13691369
13701370
Callback URL from signing service upon ICLA signature.
13711371
"""
1372-
content = body.read()
1372+
content = request.bounded_stream.read()
13731373
return cla.controllers.signing.post_individual_signed(
13741374
content, installation_id, github_repository_id, change_request_id
13751375
)
@@ -1378,7 +1378,7 @@ def post_individual_signed(
13781378
"/signed/gitlab/individual/{user_id}/{organization_id}/{gitlab_repository_id}/{merge_request_id}", versions=2,
13791379
)
13801380
def post_individual_signed_gitlab(
1381-
body,
1381+
request,
13821382
user_id: hug.types.uuid,
13831383
organization_id: hug.types.text,
13841384
gitlab_repository_id: hug.types.number,
@@ -1389,25 +1389,25 @@ def post_individual_signed_gitlab(
13891389
13901390
Callback URL from signing service upon ICLA signature for a Gitlab user.
13911391
"""
1392-
content = body.read()
1392+
content = request.bounded_stream.read()
13931393
return cla.controllers.signing.post_individual_signed_gitlab(
13941394
content, user_id, organization_id, gitlab_repository_id, merge_request_id
13951395
)
13961396

13971397

13981398
@hug.post("/signed/gerrit/individual/{user_id}", versions=2)
1399-
def post_individual_signed_gerrit(body, user_id: hug.types.uuid):
1399+
def post_individual_signed_gerrit(request, user_id: hug.types.uuid):
14001400
"""
1401-
POST: /signed/gerritindividual/{user_id}
1401+
POST: /signed/gerrit/individual/{user_id}
14021402
14031403
Callback URL from signing service upon ICLA signature for a Gerrit user.
14041404
"""
1405-
content = body.read()
1405+
content = request.bounded_stream.read()
14061406
return cla.controllers.signing.post_individual_signed_gerrit(content, user_id)
14071407

14081408

14091409
@hug.post("/signed/corporate/{project_id}/{company_id}", versions=2)
1410-
def post_corporate_signed(body, project_id: hug.types.uuid, company_id: hug.types.uuid):
1410+
def post_corporate_signed(request, project_id: hug.types.uuid, company_id: hug.types.uuid):
14111411
"""
14121412
POST: /signed/corporate/{project_id}/{company_id}
14131413
@@ -1416,7 +1416,7 @@ def post_corporate_signed(body, project_id: hug.types.uuid, company_id: hug.type
14161416
14171417
Callback URL from signing service upon CCLA signature.
14181418
"""
1419-
content = body.read()
1419+
content = request.bounded_stream.read()
14201420
return cla.controllers.signing.post_corporate_signed(content, str(project_id), str(company_id))
14211421

14221422

setenv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
rm -rf /tmp/aws
3+
rm -rf /tmp/.aws
44
cp -R ~/.aws /tmp/.aws
55

66
dev_arn="$(cat ./product-contractors-role.dev.secret)"

tests/functional/utils/run-single-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ then
2323
echo "Usage: $0 <test-file-name-without-extension> [test-name-regexp]"
2424
echo "Example (v4 APIs groups): V=4 $0 cla-group, cla-manager, company, docs, events, foundation, github-organizations, github-repositories, githubActivity, gitlab-organizations, gitlab-repositories, health, metrics, projects, signatures, version"
2525
echo "Example (v3 APIs groups): V=3 $0 cla-manager, docs, gerrits, github-organizations, health, project, template, version, company, events, github, github-repositories, organization, signatures, users"
26+
echo "Example (v2 APIs groups): V=2 $0 company, events, gerrit, github, health, project, repository, signatures, user"
2627
exit 1
2728
fi
2829
fi

utils/run_go_api_server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
make build-linux && PORT=5001 AUTH0_USERNAME_CLAIM_CLI='http://lfx.dev/claims/username' AUTH0_EMAIL_CLAIM_CLI='http://lfx.dev/claims/email' AUTH0_NAME_CLAIM_CLI='http://lfx.dev/claims/username' ./bin/cla
2+
cd .. && source setenv.sh && cd cla-backend-go && make build-linux && PORT=5001 AUTH0_USERNAME_CLAIM_CLI='http://lfx.dev/claims/username' AUTH0_EMAIL_CLAIM_CLI='http://lfx.dev/claims/email' AUTH0_NAME_CLAIM_CLI='http://lfx.dev/claims/username' ./bin/cla 1>golang-api.log 2>golang-api.err

utils/run_py_api_server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd .. && source setenv.sh && cd cla-backend && AUTH0_USERNAME_CLAIM_CLI='http://lfx.dev/claims/username' AUTH0_EMAIL_CLAIM_CLI='http://lfx.dev/claims/email' AUTH0_NAME_CLAIM_CLI='http://lfx.dev/claims/username' yarn serve:ext 1>python-api.log 2>python-api.err
3+
# cd .. && source setenv.sh && cd cla-backend && yarn serve:ext 1>python-api.log 2>python-api.err

0 commit comments

Comments
 (0)