You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ro...@apache.org on 2016/12/03 06:14:46 UTC

[1/2] incubator-beam git commit: Call from_p12_keyfile() with the correct arguments.

Repository: incubator-beam
Updated Branches:
  refs/heads/python-sdk 7c0bf25fa -> 9a175a5fe


Call from_p12_keyfile() with the correct arguments.

This code path is failing, because a wrong list of arguments is passed.
Fixing that uncovered that oauth2client depends on pyOpenSSL for this
call to work. I did not add this dependency to setup.py because, it does
not install cleanly in all environments.

As a workaround, users who would like to use this authentication method
could first do a 'pip install pyOpenSSL'. I added a test, that skips if 'pyOpenSSL' is not installed.


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/f23b717e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/f23b717e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/f23b717e

Branch: refs/heads/python-sdk
Commit: f23b717e7e433c30c0acee0fea8d179e6343b8b8
Parents: 7c0bf25
Author: Ahmet Altay <al...@google.com>
Authored: Fri Dec 2 13:38:31 2016 -0800
Committer: Robert Bradshaw <ro...@gmail.com>
Committed: Fri Dec 2 22:14:32 2016 -0800

----------------------------------------------------------------------
 sdks/python/apache_beam/internal/auth.py        |   6 +--
 sdks/python/apache_beam/internal/auth_test.py   |  44 +++++++++++++++++++
 sdks/python/apache_beam/tests/data/README.md    |  20 +++++++++
 .../apache_beam/tests/data/privatekey.p12       | Bin 0 -> 2452 bytes
 sdks/python/setup.py                            |   2 +-
 5 files changed, 68 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/f23b717e/sdks/python/apache_beam/internal/auth.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/internal/auth.py b/sdks/python/apache_beam/internal/auth.py
index a043fcf..056f40c 100644
--- a/sdks/python/apache_beam/internal/auth.py
+++ b/sdks/python/apache_beam/internal/auth.py
@@ -133,6 +133,7 @@ def get_service_credentials():
         'https://www.googleapis.com/auth/datastore'
     ]
 
+    # TODO(BEAM-1068): Do not recreate options from sys.argv.
     # We are currently being run from the command line.
     google_cloud_options = PipelineOptions(
         sys.argv).view_as(GoogleCloudOptions)
@@ -151,8 +152,8 @@ def get_service_credentials():
         return ServiceAccountCredentials.from_p12_keyfile(
             google_cloud_options.service_account_name,
             google_cloud_options.service_account_key_file,
-            client_scopes,
-            user_agent=user_agent)
+            private_key_password=None,
+            scopes=client_scopes)
       except ImportError:
         with file(google_cloud_options.service_account_key_file) as f:
           service_account_key = f.read()
@@ -162,7 +163,6 @@ def get_service_credentials():
             service_account_key,
             client_scopes,
             user_agent=user_agent)
-
     else:
       try:
         credentials = _GCloudWrapperCredentials(user_agent)

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/f23b717e/sdks/python/apache_beam/internal/auth_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/internal/auth_test.py b/sdks/python/apache_beam/internal/auth_test.py
new file mode 100644
index 0000000..dfd408e
--- /dev/null
+++ b/sdks/python/apache_beam/internal/auth_test.py
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""Unit tests for the auth module."""
+
+import os
+import sys
+import unittest
+
+import mock
+
+from apache_beam.internal import auth
+
+
+class AuthTest(unittest.TestCase):
+
+  def test_create_application_client(self):
+    try:
+      test_args = [
+          'test', '--service_account_name', 'abc', '--service_account_key_file',
+          os.path.join(
+              os.path.dirname(__file__), '..', 'tests/data/privatekey.p12')]
+      with mock.patch.object(sys, 'argv', test_args):
+        credentials = auth.get_service_credentials()
+        self.assertIsNotNone(credentials)
+    except NotImplementedError:
+      self.skipTest('service account tests require pyOpenSSL module.')
+
+
+if __name__ == '__main__':
+  unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/f23b717e/sdks/python/apache_beam/tests/data/README.md
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/tests/data/README.md b/sdks/python/apache_beam/tests/data/README.md
new file mode 100644
index 0000000..5856342
--- /dev/null
+++ b/sdks/python/apache_beam/tests/data/README.md
@@ -0,0 +1,20 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+# Generating Test Data Files
+* [privatekey.p12](https://github.com/google/oauth2client/blob/master/tests/data/privatekey.p12)

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/f23b717e/sdks/python/apache_beam/tests/data/privatekey.p12
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/tests/data/privatekey.p12 b/sdks/python/apache_beam/tests/data/privatekey.p12
new file mode 100644
index 0000000..c369ecb
Binary files /dev/null and b/sdks/python/apache_beam/tests/data/privatekey.p12 differ

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/f23b717e/sdks/python/setup.py
----------------------------------------------------------------------
diff --git a/sdks/python/setup.py b/sdks/python/setup.py
index 73927bb..033afc7 100644
--- a/sdks/python/setup.py
+++ b/sdks/python/setup.py
@@ -112,7 +112,7 @@ setuptools.setup(
     author=PACKAGE_AUTHOR,
     author_email=PACKAGE_EMAIL,
     packages=setuptools.find_packages(),
-    package_data={'apache_beam': ['**/*.pyx', '**/*.pxd']},
+    package_data={'apache_beam': ['**/*.pyx', '**/*.pxd', 'tests/data/*']},
     ext_modules=cythonize([
         '**/*.pyx',
         'apache_beam/coders/coder_impl.py',


[2/2] incubator-beam git commit: Closes #1491

Posted by ro...@apache.org.
Closes #1491


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/9a175a5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/9a175a5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/9a175a5f

Branch: refs/heads/python-sdk
Commit: 9a175a5fe17d087f2c3ca0ff8e6d53faad6beab4
Parents: 7c0bf25 f23b717
Author: Robert Bradshaw <ro...@gmail.com>
Authored: Fri Dec 2 22:14:33 2016 -0800
Committer: Robert Bradshaw <ro...@gmail.com>
Committed: Fri Dec 2 22:14:33 2016 -0800

----------------------------------------------------------------------
 sdks/python/apache_beam/internal/auth.py        |   6 +--
 sdks/python/apache_beam/internal/auth_test.py   |  44 +++++++++++++++++++
 sdks/python/apache_beam/tests/data/README.md    |  20 +++++++++
 .../apache_beam/tests/data/privatekey.p12       | Bin 0 -> 2452 bytes
 sdks/python/setup.py                            |   2 +-
 5 files changed, 68 insertions(+), 4 deletions(-)
----------------------------------------------------------------------