Skip to content

Commit 460cd9f

Browse files
authored
Merge pull request #82 from paulioceano/spa-automated
Spa automated
2 parents 59faebe + a107191 commit 460cd9f

6 files changed

Lines changed: 127 additions & 0 deletions

File tree

.circleci/config.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Environment variables to be defined in the build configuration:
2+
# AUTH0_TEST_CLIENT_ID = Client id to use in test
3+
# AUTH0_TEST_DOMAIN = Domain to use in test
4+
# AUTH0_TEST_API_IDENTIFIER = API Audience to use in test
5+
6+
# Common logic
7+
defaults: &defaults
8+
steps:
9+
- attach_workspace:
10+
at: ~/
11+
- run:
12+
name: Replace Auth0 test credentials
13+
command: |
14+
echo "export const AUTH_CONFIG = {" >> $AUTH0_CFG
15+
echo " clientId: '$AUTH0_TEST_CLIENT_ID'," >> $AUTH0_CFG
16+
echo " domain: '$AUTH0_TEST_DOMAIN'," >> $AUTH0_CFG
17+
echo " callbackUrl: 'http://localhost:3000/callback'," >> $AUTH0_CFG
18+
echo " apiUrl: '$AUTH0_TEST_AUDIENCE'" >> $AUTH0_CFG
19+
echo "}" >> $AUTH0_CFG
20+
21+
- run:
22+
name: Build pull request
23+
command: |
24+
docker build -t $CIRCLE_JOB ./$SAMPLE_PATH
25+
docker run -d -p 3000:3000 --name $CIRCLE_SHA1 -e AUTH0_DOMAIN=$AUTH0_TEST_DOMAIN -e AUTH0_AUDIENCE=$AUTH0_TEST_API_IDENTIFIER $CIRCLE_JOB
26+
- run:
27+
name: Wait for app to be available
28+
command: |
29+
sleep 10
30+
docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:3000
31+
- run:
32+
name: Run tests
33+
command: |
34+
docker create --network host --name tester codeception/codeceptjs codeceptjs run-multiple --all --steps --verbose
35+
docker cp $(pwd)/lock_login_test.js tester:/tests/lock_login_test.js
36+
docker cp $(pwd)/codecept.conf.js tester:/tests/codecept.conf.js
37+
docker start -i tester
38+
working_directory: scripts
39+
- run:
40+
name: Copy app container logs
41+
command: |
42+
mkdir -p /tmp/out
43+
docker logs $CIRCLE_SHA1 > /tmp/out/app_logs.log
44+
docker cp tester:/tests/out /tmp/
45+
when: on_fail
46+
- store_artifacts:
47+
path: /tmp/out
48+
49+
# Jobs and Workflows
50+
version: 2
51+
jobs:
52+
checkout:
53+
machine: true
54+
steps:
55+
- checkout
56+
- run: git clone https://github.com/auth0-samples/spa-quickstarts-tests scripts
57+
- persist_to_workspace:
58+
root: ~/
59+
paths:
60+
- project
61+
- scripts
62+
01-login:
63+
machine: true
64+
environment:
65+
- AUTH0_CFG: 01-Login/src/Auth/auth0-variables.js
66+
- SAMPLE_PATH: 01-Login
67+
<<: *defaults
68+
02-user-profile:
69+
machine: true
70+
environment:
71+
- AUTH0_CFG: 02-User-Profile/src/Auth/auth0-variables.js
72+
- SAMPLE_PATH: 02-User-Profile
73+
<<: *defaults
74+
03-calling-an-api:
75+
machine: true
76+
environment:
77+
- AUTH0_CFG: 03-Calling-an-API/src/Auth/auth0-variables.js
78+
- SAMPLE_PATH: 03-Calling-an-API
79+
<<: *defaults
80+
04-authorization:
81+
machine: true
82+
environment:
83+
- AUTH0_CFG: 04-Authorization/src/Auth/auth0-variables.js
84+
- SAMPLE_PATH: 04-Authorization
85+
<<: *defaults
86+
05-token-renewal:
87+
machine: true
88+
environment:
89+
- AUTH0_CFG: 05-Token-Renewal/src/Auth/auth0-variables.js
90+
- SAMPLE_PATH: 05-Token-Renewal
91+
<<: *defaults
92+
93+
workflows:
94+
version: 2
95+
quickstarts_login:
96+
jobs:
97+
- checkout:
98+
context: Quickstart SPA Test
99+
- 01-login:
100+
context: Quickstart SPA Test
101+
requires:
102+
- checkout
103+
- 02-user-profile:
104+
context: Quickstart SPA Test
105+
requires:
106+
- checkout
107+
- 03-calling-an-api:
108+
context: Quickstart SPA Test
109+
requires:
110+
- checkout
111+
- 04-authorization:
112+
context: Quickstart SPA Test
113+
requires:
114+
- checkout
115+
- 05-token-renewal:
116+
context: Quickstart SPA Test
117+
requires:
118+
- checkout

02-User-Profile/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class App extends Component {
3535
{
3636
!isAuthenticated() && (
3737
<Button
38+
id="qsLoginBtn"
3839
bsStyle="primary"
3940
className="btn-margin"
4041
onClick={this.login.bind(this)}
@@ -57,6 +58,7 @@ class App extends Component {
5758
{
5859
isAuthenticated() && (
5960
<Button
61+
id="qsLogoutBtn"
6062
bsStyle="primary"
6163
className="btn-margin"
6264
onClick={this.logout.bind(this)}

03-Calling-an-API/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class App extends Component {
3535
{
3636
!isAuthenticated() && (
3737
<Button
38+
id="qsLoginBtn"
3839
bsStyle="primary"
3940
className="btn-margin"
4041
onClick={this.login.bind(this)}
@@ -68,6 +69,7 @@ class App extends Component {
6869
{
6970
isAuthenticated() && (
7071
<Button
72+
id="qsLogoutBtn"
7173
bsStyle="primary"
7274
className="btn-margin"
7375
onClick={this.logout.bind(this)}

04-Authorization/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class App extends Component {
3535
{
3636
!isAuthenticated() && (
3737
<Button
38+
id="qsLoginBtn"
3839
bsStyle="primary"
3940
className="btn-margin"
4041
onClick={this.login.bind(this)}
@@ -79,6 +80,7 @@ class App extends Component {
7980
{
8081
isAuthenticated() && (
8182
<Button
83+
id="qsLogoutBtn"
8284
bsStyle="primary"
8385
className="btn-margin"
8486
onClick={this.logout.bind(this)}

05-Token-Renewal/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class App extends Component {
3838
</Button>
3939
{!isAuthenticated() &&
4040
<Button
41+
id="qsLoginBtn"
4142
bsStyle="primary"
4243
className="btn-margin"
4344
onClick={this.login.bind(this)}
@@ -62,6 +63,7 @@ class App extends Component {
6263
</Button>}
6364
{isAuthenticated() &&
6465
<Button
66+
id="qsLogoutBtn"
6567
bsStyle="primary"
6668
className="btn-margin"
6769
onClick={this.logout.bind(this)}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Auth0 React Samples
22

3+
34
These samples demonstrate how to add authentication to a React application with Auth0. Each folder contains a distinct application so that various Auth0 features can be viewed in isolation. You can read about these examples in our [React Quickstart](https://auth0.com/docs/quickstart/spa/react).
45

56
## Embedded Integration Samples

0 commit comments

Comments
 (0)