Skip to content

Commit

Permalink
Merge branch 'main' into fix-explicit-token-caching-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Oct 15, 2024
2 parents 3819ee2 + 76c312e commit 2aec94e
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 91 deletions.
21 changes: 0 additions & 21 deletions .github/actions/docs/entrypoint.sh

This file was deleted.

29 changes: 0 additions & 29 deletions .github/actions/docs/sami.php

This file was deleted.

3 changes: 1 addition & 2 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ branchProtectionRules:
- pattern: master
isAdminEnforced: true
requiredStatusCheckContexts:
- 'PHP 7.4 Unit Test'
- 'PHP 7.4 --prefer-lowest Unit Test'
- 'PHP 8.0 Unit Test'
- 'PHP 8.0 --prefer-lowest Unit Test'
- 'PHP 8.1 Unit Test'
- 'PHP 8.2 Unit Test'
- 'PHP 8.3 Unit Test'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/asset-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php: [ "7.4", "8.0", "8.2" ]
php: [ "8.0", "8.3" ]

name: Upload Release Assets
steps:
Expand Down
45 changes: 20 additions & 25 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
name: Generate Documentation
on:
push:
branches: [main]
tags:
- "*"
workflow_dispatch:
inputs:
tag:
description: 'Tag to generate documentation for'
required: false
pull_request:

permissions:
contents: write

jobs:
docs:
name: "Generate Project Documentation"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 10
max_attempts: 3
command: composer install
- name: Generate and Push Documentation
uses: docker://php:7.4-cli
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
entrypoint: ./.github/actions/docs/entrypoint.sh
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: .docs
name: "Generate and Deploy Documentation"
uses: GoogleCloudPlatform/php-tools/.github/workflows/doctum.yml@main
with:
title: "Google Cloud PHP Client"
default_version: ${{ inputs.tag || github.head_ref || github.ref_name }}
exclude_file: aliases.php
tag_pattern: "v2.*"
dry_run: ${{ github.event_name == 'pull_request' }}

4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
php: [ "8.0", "8.1", "8.2", "8.3" ]
composer-flags: [""]
include:
- php: "7.4"
- php: "8.0"
composer-flags: "--prefer-lowest "
- php: "8.3"
composer-flags: "--prefer-lowest "
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [2.17.0](https://github.com/googleapis/google-api-php-client/compare/v2.16.0...v2.17.0) (2024-07-10)


### Features

* Add logger to client constructor config ([#2606](https://github.com/googleapis/google-api-php-client/issues/2606)) ([1f47133](https://github.com/googleapis/google-api-php-client/commit/1f4713329d71111a317cda8ef8603fa1bdc88858))
* Add the protected apiVersion property ([#2588](https://github.com/googleapis/google-api-php-client/issues/2588)) ([7e79f3d](https://github.com/googleapis/google-api-php-client/commit/7e79f3d7be4811f760e19cc4a2c558e04196ec1d))

## [2.16.0](https://github.com/googleapis/google-api-php-client/compare/v2.15.4...v2.16.0) (2024-04-24)


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ list of [Google cloud packages](https://cloud.google.com/php/docs/reference) fir
these are the recommended libraries.

<dl>
<dt>Reference Docs</dt><dd><a href="https://googleapis.github.io/google-api-php-client/main/">https://googleapis.github.io/google-api-php-client/main/</a></dd>
<dt>Reference Docs</dt><dd><a href="https://googleapis.github.io/google-api-php-client/">https://googleapis.github.io/google-api-php-client/</a></dd>
<dt>License</dt><dd>Apache 2.0</dd>
</dl>

Expand All @@ -25,7 +25,7 @@ For Google Cloud Platform APIs such as [Datastore][cloud-datastore], [Cloud Stor
[cloud-compute]: https://github.com/googleapis/google-cloud-php-compute

## Requirements ##
* [PHP 7.4 or higher](https://www.php.net/)
* [PHP 8.0 or higher](https://www.php.net/)

## Developer Documentation ##

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"homepage": "http://developers.google.com/api-client-library/php",
"license": "Apache-2.0",
"require": {
"php": "^7.4|^8.0",
"php": "^8.0",
"google/auth": "^1.37",
"google/apiclient-services": "~0.350",
"firebase/php-jwt": "~6.0",
"firebase/php-jwt": "^6.0",
"monolog/monolog": "^2.9||^3.0",
"phpseclib/phpseclib": "^3.0.36",
"guzzlehttp/guzzle": "^6.5.8||^7.4.5",
"guzzlehttp/psr7": "^1.9.1||^2.2.1"
"guzzlehttp/guzzle": "^7.4.5",
"guzzlehttp/psr7": "^2.6"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.8",
Expand All @@ -22,8 +22,8 @@
"cache/filesystem-adapter": "^1.1",
"phpcompatibility/php-compatibility": "^9.2",
"composer/composer": "^1.10.23",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5"
"phpspec/prophecy-phpunit": "^2.1",
"phpunit/phpunit": "^9.6"
},
"suggest": {
"cache/filesystem-adapter": "For caching certs and tokens (using Google\\Client::setCache)"
Expand Down
9 changes: 8 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public function __construct(array $config = [])
'prompt' => '',
'openid.realm' => '',
'include_granted_scopes' => null,
'logger' => null,
'login_hint' => '',
'request_visible_actions' => '',
'access_type' => 'online',
Expand Down Expand Up @@ -242,6 +243,11 @@ public function __construct(array $config = [])
$this->setCache($this->config['cache']);
unset($this->config['cache']);
}

if (!is_null($this->config['logger'])) {
$this->setLogger($this->config['logger']);
unset($this->config['logger']);
}
}

/**
Expand Down Expand Up @@ -1037,7 +1043,8 @@ public function setAuthConfig($config)

$key = isset($config['installed']) ? 'installed' : 'web';
if (isset($config['type']) && $config['type'] == 'service_account') {
// application default credentials
// @TODO(v3): Remove this, as it isn't accurate. ADC applies only to determining
// credentials based on the user's environment.
$this->useApplicationDefaultCredentials();

// set the information from the config
Expand Down
17 changes: 15 additions & 2 deletions tests/Google/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ public function testDefaultLoggerAppEngine()
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
}

public function testLoggerFromConstructor()
{
$logger1 = new \Monolog\Logger('unit-test');
$client = new Client(['logger' => $logger1]);
$logger2 = $client->getLogger();
$this->assertInstanceOf('Monolog\Logger', $logger2);
$this->assertEquals('unit-test', $logger2->getName());
$this->assertSame($logger1, $logger2);
}

public function testSettersGetters()
{
$client = new Client();
Expand All @@ -279,6 +289,7 @@ public function testSettersGetters()

$client->setRedirectUri('localhost');
$client->setConfig('application_name', 'me');
$client->setLogger(new \Monolog\Logger('test'));

$cache = $this->prophesize(CacheItemPoolInterface::class);
$client->setCache($cache->reveal());
Expand Down Expand Up @@ -703,8 +714,10 @@ public function testOnGceCacheAndCacheOptions()
$mockCache->getItem($prefix . GCECache::GCE_CACHE_KEY)
->shouldBeCalledTimes(1)
->willReturn($mockCacheItem->reveal());
$mockCache->getItem(GCECredentials::cacheKey . 'universe_domain')
->shouldBeCalledTimes(1)
// cache key from GCECredentials::getTokenUri() . 'universe_domain'
$mockCache->getItem('cc685e3a0717258b6a4cefcb020e96de6bcf904e76fd9fc1647669f42deff9bf') // google/auth < 1.41.0
->willReturn($mockUniverseDomainCacheItem->reveal());
$mockCache->getItem(GCECredentials::cacheKey . 'universe_domain') // google/auth >= 1.41.0
->willReturn($mockUniverseDomainCacheItem->reveal());

$client = new Client(['cache_config' => $cacheConfig]);
Expand Down

0 comments on commit 2aec94e

Please sign in to comment.