Skip to content

Commit

Permalink
prepare for final v1 release (#22)
Browse files Browse the repository at this point in the history
* updated v1

* some more comments

* clarity

* update makefile

* add duration checks for all performance tests
  • Loading branch information
Harry Bragg authored Jun 5, 2017
1 parent ff1c4b5 commit 915aa4d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All Notable changes to `gigya-client` will be documented in this file

## 1.0 - 2016-11-28
## 1.0 - 2016-12-02

### Changed
- Upgrade Guzzle from v5 to v6
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ DOCKER ?= $(shell which docker)
DOCKER_REPOSITORY := graze/php-alpine
VOLUME := /srv
VOLUME_MAP := -v $$(pwd):${VOLUME}
DOCKER_TAG := test
DOCKER_RUN_BASE := ${DOCKER} run --rm -t ${VOLUME_MAP} -w ${VOLUME}
DOCKER_RUN := ${DOCKER_RUN_BASE} ${DOCKER_REPOSITORY}:test
DOCKER_RUN := ${DOCKER_RUN_BASE} ${DOCKER_REPOSITORY}:${DOCKER_TAG}

.PHONY: install composer clean help
.PHONY: test lint lint-fix test-unit test-integration test-matrix test-coverage test-coverage-html test-coverage-clover

.SILENT: help
.DEFAULT_GOAL=help

# Building

install: ## Download the dependencies then build the image :rocket:.
install: ## Download the dependencies then build the image 🚀
make 'composer-install --optimize-autoloader --ignore-platform-reqs'

composer-%: ## Run a composer command, `make "composer-<command> [...]"`.
Expand All @@ -24,9 +26,6 @@ composer-%: ## Run a composer command, `make "composer-<command> [...]"`.
-v ~/.ssh:/root/.ssh:ro \
composer/composer:alpine --ansi --no-interaction $* $(filter-out $@,$(MAKECMDGOALS))

clean: ## Clean up any images.
$(DOCKER) rmi ${DOCKER_REPOSITORY}:latest

# Testing

test: ## Run the unit and integration testsuites.
Expand All @@ -42,8 +41,9 @@ test-unit: ## Run the unit testsuite.
$(DOCKER_RUN) vendor/bin/phpunit --colors=always --testsuite unit

test-matrix: ## Run the unit tests against multiple targets.
make DOCKER_RUN="${DOCKER_RUN_BASE} php:5.6-cli" test
make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.0-cli" test
make DOCKER_RUN="${DOCKER_RUN_BASE} php:5.6-alpine" test
make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.0-alpine" test
make DOCKER_RUN="${DOCKER_RUN_BASE} php:7.1-alpine" test
make DOCKER_RUN="${DOCKER_RUN_BASE} diegomarangoni/hhvm:cli" test

test-integration: ## Run the integration testsuite.
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ Client for Gigya's REST API

* Endpoint call hierarchy: `$gigya->accounts()->tfa()->getCertificate()`
* List of endpoints: `accounts`, `accounts->tfa`, `audit`, `socialize`, `comments`, `gameMechanics`, `reports`, `dataStore`, `identityStorage`, `saml`, `saml->idp`
* Populated classes with auto completion helpers for the available methods from Gigya
* Different authentication methods:
* `standard`: add api_key and secret to https web requests
* `gigya-oauth2`: gets an oauth2 token and uses that each time
* `custom`: provide you own token retrieved independently
* `gigya`: add `api_key` and `secret` to https web requests
* `credentials`: uses `client_id` and `client_secret` for use with oauth2 token retrieval
* `gigya-oauth2`: uses an automatically retrieved OAuth2 token
* `custom`: use your own custom authentication (or use oauth2 with a provided token)

## Install

Expand All @@ -28,14 +30,21 @@ $ composer require graze/gigya-client

## Usage

By Default the Gigya client uses `gigya` auth and appends the api_key and secret onto the query string when calling gigya over https.

```php
$gigya = new Gigya($key, $secret);

$response = $gigya->accounts()->getAccountInfo(['uid' => $uid]);
$account = $response->getData();
if ($response->getErrorCode() === ErrorCode::OK) {
$account = $response->getData();
}
```

### OAuth 2

You can also use `oauth2` in server mode and retrieve information about all accounts

```php
$gigya = new Gigya($key, $secret, $region, $user, ['auth'=>'gigya-oauth2']);
$response = $gigya->accounts()->getAccountInfo(['uid' => $uid]);
Expand All @@ -44,10 +53,12 @@ $account = $response->getData();

#### Social OAuth 2

OAuth2 can also be used to retrieve information about a single account without knowledge of the `uid`.

```php
$grant = new ManualGrant();
$gigya = new Gigya($key, $secret, $region, null, ['auth' => 'oauth2-custom']);
$gigya->addHandler(OAuth2Subscriber::middleware($grant));
$gigya->addHandler(OAuth2Subscriber::middleware($grant, 'oauth2-custom'));

$tokenResponse = $gigya->socialize()->getToken([
'grant_type' => 'code',
Expand Down
24 changes: 14 additions & 10 deletions tests/performance/GigyaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ public function testSingleCall()
$this->gigya->accounts()->getAccountInfo(['uid' => 'some_uid']);

$this->printBenchmark(__METHOD__, 1);

list($duration) = $this->endBenchmark();
static::assertLessThan(
1000,
$duration,
'An individual request should take less than 2s of prep and response validation'
);
}

public function testSingleChildCall()
Expand All @@ -145,6 +152,13 @@ public function testSingleChildCall()
}

$this->printBenchmark(__METHOD__, $num);

list($duration) = $this->endBenchmark();
static::assertLessThan(
1000,
$duration,
'An individual request should take less than 2s of prep and response validation'
);
}

public function testDoubleChildCall()
Expand Down Expand Up @@ -185,14 +199,4 @@ public function testUidValidationResponse()
'An individual request should take less than 2ms of prep and response validation'
);
}

public function testSingleCallAgain()
{
$this->createBasicHandler();
$this->startBenchmark();

$this->gigya->accounts()->getAccountInfo(['uid' => 'some_uid']);

$this->printBenchmark(__METHOD__, 1);
}
}

0 comments on commit 915aa4d

Please sign in to comment.