Skip to content

Commit

Permalink
Add instructions for running locally
Browse files Browse the repository at this point in the history
  • Loading branch information
lindseydew committed Apr 9, 2024
1 parent addae06 commit 35ad99a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 228 deletions.
44 changes: 1 addition & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,49 +74,7 @@ Try(mapper.readValue[List[SavedArticle]](json)) match {
*NB: I found that when a user record has 350+ articles the resultant string in too long for idea to handle.
## Running apps locally
### Pre-requisites
- Mobile credentials from [Janus](https://janus.gutools.co.uk/login)
- Install [AWS Sam](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)
- Install [Docker](https://docs.docker.com/engine/install/)
- Make sure you run the app with Java 11
### Mobile Save For Later
Build a jar of the project by running:
- `sbt "project mobile-save-for-later" riffRaffPackageType`
Navigate to the project
- `cd mobile-save-for-later`
Run the lambda service
- `DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local start-lambda --debug`
Execute a function locally
- `DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local invoke`
Execute a function using AWS cli
- `aws lambda invoke --function-name "mobilesaveforlaterFETCHcdkCODE" --endpoint-url "http://127.0.0.1:3001" --no-verify-ssl out.txt --profile mobile --region eu-west-1`
### Mobile Save For Later User Deletion
Build a jar of the project by running:
- `sbt "project mobile-save-for-later-user-deletion" riffRaffPackageType`
Navigate to the project
- `cd mobile-save-for-later-user-deletion`
Run the lambda service
- `DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local start-lambda --debug`
Execute a function locally
- `DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local invoke`
Execute a function using AWS cli
- `aws lambda invoke --function-name "mobilesaveforlateruserdeletionCODE" --endpoint-url "http://127.0.0.1:3001" --no-verify-ssl out.txt --profile mobile --region eu-west-1`
## Testing the Apps on CODE
## Testing the Apps on CODE and running Locally
[Save For Later App](docs/testing/save-for-later.md)
Expand Down
17 changes: 15 additions & 2 deletions docs/testing/save-for-later.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Pre-requisites
### Setting Up Oauth Flow
1) Download [Postman](https://www.postman.com/downloads/)
2) Set up acquiring an OKTA Auth token following these [instructions](https://github.com/guardian/identity/blob/a19ac17655fd715f15e8d0912b39173c199a8439/docs/postman/README.md)

Expand Down Expand Up @@ -32,4 +32,17 @@
2) Under the `Authorization` tab, on the type dropdown select `Bearer Token` and paste in the token generated from the Okta auth
![Authorization](../images/Authorization.png)
3) Under the `Headers` tab add `x-gu-is-oauth: true`
![Headers](../images/GetHeaders.png)
![Headers](../images/GetHeaders.png)


## Testing locally
### Pre-requisites
1) Mobile credentials from [Janus](https://janus.gutools.co.uk/login)
2) Follow the authentication flow as outlined at the [top](#setting-up-oauth-flow)

* Go to `src/main/scala/com/gu/sfl/local/LocalServer.scala`
* Select the drop down menu to the left of the run button and select `LocalServer` under run configurations
* Then choose `Edit Configurations`
* Add the following environment variables:
`App=mobile-save-for-later;IdentityApiHost=https://id.code.dev-guardianapis.com;IdentityOktaAudience=https://profile.code.dev-theguardian.com/;IdentityOktaIssuerUrl=https://profile.code.dev-theguardian.com/oauth2/aus3v9gla95Toj0EE0x7;Stage=CODE;SavedArticleLimit=100`
* Follow the same steps as above for testing the GET and POST endpoints by changing the host to `http://127.0.0.1:8080`
17 changes: 15 additions & 2 deletions docs/testing/user-deletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
"messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
"receiptHandle": "MessageReceiptHandle",
"body": "{\"Message\": { \"userId\": \"1\"}}",
"body": "{\"Message\": \"{\\\"userId\\\":\\\"200126633\\\",\\\"eventType\\\":\\\"DELETE\\\"}\"}",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1523232000000",
Expand All @@ -30,4 +30,17 @@
}
]
}
```
```

## Testing locally

### Pre-requisites
1) Mobile credentials from [Janus](https://janus.gutools.co.uk/login)

* Go to `src/main/scala/local/RunUserDeletionLambda.scala`
* Select the drop down menu to the left of the run button and select `RunUserDeletionLambda` under run configurations
* Then choose `Edit Configurations`
* Add the following environment variables:
* `SaveForLaterApp=mobile-save-for-later;Stage=CODE`
* Modify the event json at `src/main/resources/delete-event.json` to have the user id you want
* Hit the green run button
84 changes: 0 additions & 84 deletions mobile-save-for-later-user-deletion/template.yml

This file was deleted.

97 changes: 0 additions & 97 deletions mobile-save-for-later/template.yml

This file was deleted.

0 comments on commit 35ad99a

Please sign in to comment.