Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Add support for user credentials/jwt #5

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
env.sh
.nyc_output
coverage
.tern-port
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ Wrapper library for Topcoder Submission API

```javascript
const submissionApi = require('topcoder-submission-api-wrapper')
const submissionApiClient = submissionApi(_.pick(config,
const submissionApiM2MClient = submissionApi(_.pick(config,
['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'SUBMISSION_API_URL',
'AUTH0_PROXY_SERVER_URL']))
```

**Configuration / Environment variables:**

**M2M Authentication Configuration:**
- AUTH0_URL - the auth0 url
- AUTH0_AUDIENCE - the auth0 audience
- TOKEN_CACHE_TIME - (optional) the token cache time
Expand All @@ -33,6 +32,29 @@ Wrapper library for Topcoder Submission API
- PER_PAGE - the page size
- MAX_PAGE_SIZE - the max number of page size

```javascript
const submissionApiUserCredentialsClient = submissionApi(_.pick(config,
['USERNAME', 'PASSWORD', 'TC_AUTHN_URL', 'TC_AUTHZ_URL', 'TC_CLIENT_ID',
'TC_CLIENT_V2CONNECTION', 'SUBMISSION_API_URL']))
```

**User Credentials Authentication Configuration:**
- USERNAME - Topcoder handle
- PASSWORD - Topcoder password
- TC_AUTHN_URL - OAUTH2 token URL, e.g. `https://topcoder.auth0.com/oauth/ro` or for dev `https://topcoder-dev.auth0.com/oauth/ro`
- TC_AUTHZ_URL - Topcoder API token URL, e.g. `https://api.topcoder.com/v3/authorizations` or for dev `https://api.topcoder-dev.com/v3/authorizations`
- TC_CLIENT_ID - OAUTH2 Client ID, e.g. `6ZwZEUo2ZK4c50aLPpgupeg5v2Ffxp9P` or for dev `JFDo7HMkf0q2CkVFHojy3zHWafziprhT`
- TC_CLIENT_V2CONNECTION - The OAUTH2 Client data source, e.g. `TC-User-Database`
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder.com/v5` or for dev `https://api.topcoder-dev.com/v5`

```javascript
const submissionJwtMethodArgClient = submissionApi(_.pick(config,
['SUBMISSION_API_URL']))
```

**JWT Method Argument Authentication Configuration:**
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder.com/v5` or for dev `https://api.topcoder-dev.com/v5`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: So the JWT way is to only pass the submission api url and then pass the token each time any method is called? 🤔 hmm... Not sure why the constructor didn't accept the jwt token itself... assuming it is because it allows us to use different tokens for each method...


3. Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments

E.g.
Expand Down Expand Up @@ -126,6 +148,13 @@ Following environment variables need to be set up before running the tests
- TEST_AUTH0_CLIENT_ID
- TEST_AUTH0_CLIENT_SECRET
- TEST_SUBMISSION_API_URL
- TEST_JWT
- TEST_USERNAME
- TEST_PASSWORD
- TEST_TC_AUTHN_URL
- TEST_TC_AUTHZ_URL
- TEST_TC_CLIENT_ID
- TEST_TC_CLIENT_V2CONNECTION
```

Refer to Step # 2 in [this section](#how-to-use-this-wrapper) to learn more about the configuration variables.
Expand Down
28 changes: 15 additions & 13 deletions Verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@

## Test Coverage Report

226 passing (5m)
668 passing

File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------------------------|----------|----------|----------|----------|-------------------
All files | 99.42 | 90 | 100 | 99.42 |
topcoder-submission-api-wrapper | 100 | 100 | 100 | 100 |
index.js | 100 | 100 | 100 | 100 |
topcoder-submission-api-wrapper/src | 100 | 100 | 100 | 100 |
ReviewSummationsApi.js | 100 | 100 | 100 | 100 |
ReviewTypesApi.js | 100 | 100 | 100 | 100 |
ReviewsApi.js | 100 | 100 | 100 | 100 |
SubmissionsApi.js | 100 | 100 | 100 | 100 |
topcoder-submission-api-wrapper/src/common | 97.56 | 88.89 | 100 | 97.56 |
helper.js | 97.56 | 88.89 | 100 | 97.56 | 63

File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
--------------------------------------------|----------|----------|----------|----------|-------------------|
All files | 99.5 | 95.52 | 100 | 99.5 | |
topcoder-submission-api-wrapper | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
topcoder-submission-api-wrapper/src | 100 | 100 | 100 | 100 | |
ReviewSummationsApi.js | 100 | 100 | 100 | 100 | |
ReviewTypesApi.js | 100 | 100 | 100 | 100 | |
ReviewsApi.js | 100 | 100 | 100 | 100 | |
SubmissionsApi.js | 100 | 100 | 100 | 100 | |
topcoder-submission-api-wrapper/src/common | 98.25 | 88 | 100 | 98.25 | |
constants.js | 100 | 100 | 100 | 100 | |
helper.js | 98.21 | 88 | 100 | 98.21 | 134 |
Loading