Skip to content

Commit 9cc8031

Browse files
PLAT-1895 - List Scopes
* list scopes * build status * image fix * link to build * upload app root * make it easier to run the tests * fix tests wip * fix test * remove filter * fix env vars * rename callPersona method * use http_build_query * docblocks etc * move exception to it's own file * introduce exceptions per validation result * remove typo * docblocks * rename InvalidValidationException to TokenValidationException * tidy * rename file * fix tests
1 parent 08938e1 commit 9cc8031

18 files changed

+612
-157
lines changed

Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
FROM talis/ubuntu:1404-latest
22

3-
MAINTAINER Malcolm Landon "[email protected]"
4-
53
ENV DEBIAN_FRONTEND noninteractive
64

75
ARG git_oauth_token
86
ARG persona_oauth_client
97
ARG persona_oauth_secret
108

11-
RUN apt-get update && apt-get upgrade -y
12-
13-
RUN apt-get install -y --force-yes curl apt-transport-https && curl -L http://apt.talis.com:81/public.key | sudo apt-key add - && apt-get update
9+
RUN apt-get update \
10+
&& apt-get install -y --force-yes curl apt-transport-https \
11+
&& curl -L http://apt.talis.com:81/public.key | sudo apt-key add - \
12+
&& apt-get update \
13+
&& apt-get upgrade -y
1414

1515
# Install php and ant
1616
RUN apt-get install --no-install-recommends -y \
@@ -41,12 +41,13 @@ RUN apt-get -y autoremove && apt-get clean && apt-get autoclean && \
4141
RUN mkdir -p /var/talis-php
4242
COPY . /var/talis-php
4343

44-
RUN echo 'export PERSONA_TEST_HOST=https://staging-users.talis.com' >> /root/.bashrc
45-
RUN echo 'export PERSONA_TEST_OAUTH_CLIENT='$persona_oauth_client >> /root/.bashrc
46-
RUN echo 'export PERSONA_TEST_OAUTH_SECRET='$persona_oauth_secret >> /root/.bashrc
44+
RUN echo "export PERSONA_TEST_HOST='https://staging-users.talis.com'" >> /etc/profile.d/test.sh \
45+
&& echo "export PERSONA_TEST_OAUTH_CLIENT='$persona_oauth_client'" >> /etc/profile.d/test.sh \
46+
&& echo "export PERSONA_TEST_OAUTH_SECRET='$persona_oauth_secret'" >> /etc/profile.d/test.sh \
47+
&& chmod 775 /etc/profile.d/test.sh
4748

4849
WORKDIR /var/talis-php
4950

5051
RUN ant init
5152

52-
CMD /bin/bash -c "service redis-server start && ant test"
53+
CMD /bin/bash -c "service redis-server start && source /etc/profile.d/* && ant test"

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
talis-php
1+
talis-php [![build status](https://travis-ci.org/talis/talis-php.svg?branch=master)](https://travis-ci.org/talis/talis-php)
2+
23
=========
34

45
# Development Version - Not For General Use
@@ -7,35 +8,31 @@ This is a development version of the new talis-php version. It is not yet intend
78
This early version pulls existing individual client libraries into one single library with minimal
89
changes.
910

10-
Before releasing for general usage there will be major changes to the API. The library will move
11+
Before releasing for general usage there will be major changes to the API. The library will move
1112
away from the use of internal Talis project names like Persona, Critic, Babel and Echo etc.
1213
Instead it will use more externally relavant names like ```ListReviews``` and ```Files```.
1314
The API will also move to a more domain driven design rather than the service driven design
1415
of the individual libraries
1516

1617
See issue: https://github.com/talis/talis-php/issues/2 and Milestone: https://github.com/talis/talis-php/milestone/1
1718

18-
1919
## Contributing
2020

2121
A Dockerfile is provided to make it easy to get a local development environment
2222
up and running to develop and test changes. Follow these steps:
2323

24-
```bash
25-
2624
# Build the development image
2725

26+
```bash
2827
git clone https://github.com/talis/talis-php.git
2928
cd talis-php
30-
docker build -t "talis-php:dev" --build-arg git_oauth_token=<your github oauth token> --build-arg persona_oauth_client=<your oauth client> --build-arg persona_oauth_secret=<your oauth client secret> .
31-
32-
# When the above has built successfully you can run and connect to the container
33-
docker run -v /path/on/host/machine/to/talis-php:/var/talis-php -i -t echo-php-client:dev /bin/bash
29+
ant build
30+
```
3431

35-
# Then inside the container
32+
# When the above has built you can run the tests
3633

37-
service redis-server start
38-
ant init
39-
ant test
34+
```bash
35+
docker-compose run test
36+
docker-compose run unittest
37+
docker-compose run integrationtest
4038
```
41-

build.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Ant build script
44
-->
55
<project default="all" name="talis-php-client" basedir=".">
6+
<property environment="env"/>
67

78
<property name="src.dir" location="src"/>
89
<property name="vendor.dir" location="vendor"/>
@@ -69,8 +70,25 @@
6970

7071
<target name="integrationtest" depends="clean">
7172
<exec dir="${integration.test.dir}" executable="${vendor.dir}/bin/phpunit" failonerror="true">
73+
<env key="PERSONA_TEST_HOST" value="${env.PERSONA_TEST_HOST}" />
74+
<env key="PERSONA_TEST_OAUTH_CLIENT" value="${env.PERSONA_TEST_OAUTH_CLIENT}" />
75+
<env key="PERSONA_TEST_OAUTH_SECRET" value="${env.PERSONA_TEST_OAUTH_SECRET}" />
7276
<arg line="--log-junit ${build.dir}/integrationtest-report.xml"/>
7377
</exec>
7478
</target>
7579

80+
<target name="build">
81+
<exec executable="/usr/bin/docker" failonerror="true">
82+
<arg value="build" />
83+
<arg value="-t" />
84+
<arg value="talis/talis-php" />
85+
<arg value="--build-arg" />
86+
<arg value="git_oauth_token=${env.git_oauth_token}" />
87+
<arg value="--build-arg" />
88+
<arg value="persona_oauth_client=${env.persona_oauth_client}" />
89+
<arg value="--build-arg" />
90+
<arg value="persona_oauth_secret=${env.persona_oauth_secret}" />
91+
<arg value="." />
92+
</exec>
93+
</target>
7694
</project>

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "talis/talis-php",
33
"description": "This is a php client library for talis api's",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"keywords": [
66
"persona",
77
"echo",

docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '2'
2+
3+
services:
4+
test:
5+
image: talis/talis-php
6+
volumes:
7+
- "./src:/var/talis-php/src"
8+
- "./test:/var/talis-php/test"
9+
- "./build.xml:/var/talis-php/build.xml"
10+
command: /bin/bash -c "service redis-server start && source /etc/profile.d/* && ant test"
11+
unittest:
12+
image: talis/talis-php
13+
volumes:
14+
- "./src:/var/talis-php/src"
15+
- "./test:/var/talis-php/test"
16+
- "./build.xml:/var/talis-php/build.xml"
17+
command: /bin/bash -c "service redis-server start && source /etc/profile.d/* && ant unittest"
18+
integrationtest:
19+
image: talis/talis-php
20+
volumes:
21+
- "./src:/var/talis-php/src"
22+
- "./test:/var/talis-php/test"
23+
- "./build.xml:/var/talis-php/build.xml"
24+
command: /bin/bash -c "service redis-server start && source /etc/profile.d/* && ant integrationtest"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace Talis\Persona\Client;
3+
4+
/**
5+
* Response from the server included a empty body.
6+
*/
7+
class EmptyResponseException extends TokenValidationException
8+
{
9+
public function __construct($msg) {
10+
parent::__construct(
11+
$msg,
12+
ValidationResults::EmptyResponse
13+
);
14+
}
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
namespace Talis\Persona\Client;
3+
4+
/**
5+
* Public key used to validate the JWT is considered invalid.
6+
*/
7+
class InvalidPublicKeyException extends TokenValidationException
8+
{
9+
public function __construct($msg) {
10+
parent::__construct(
11+
$msg,
12+
ValidationResults::InvalidPublicKey
13+
);
14+
}
15+
}
16+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace Talis\Persona\Client;
3+
4+
/**
5+
* Signature within the JWT does not represent the token.
6+
*/
7+
class InvalidSignatureException extends TokenValidationException
8+
{
9+
public function __construct($msg)
10+
parent::__construct(
11+
$msg,
12+
ValidationResults::InvalidSignature
13+
);
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace Talis\Persona\Client;
3+
4+
/**
5+
* Either the token is malformed or it has expired.
6+
*/
7+
class InvalidTokenException extends TokenValidationException
8+
{
9+
public function __construct($msg) {
10+
parent::__construct(
11+
$msg,
12+
ValidationResults::InvalidToken
13+
);
14+
}
15+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22
namespace Talis\Persona\Client;
33

4+
/**
5+
* API returned a not found.
6+
*/
47
class NotFoundException extends \Exception
58
{
6-
}
9+
}

0 commit comments

Comments
 (0)