[auth] Delete spotify_auth_provider
Spotify auth provider is not currently being used by any client mod.
Its causing maintenance issues to keep supporting ongoing chrome,
scenic/component underlying changes. At this point we consider this
as dead code and will revisit it in the future if needed.
TESTED = CI/CQ, deleted spotify_unittests target.
Change-Id: I6893fe85df7eab4ee6bf6495ce6f2d34f7dfff9c
diff --git a/auth_providers/BUILD.gn b/auth_providers/BUILD.gn
index 02a1d48..0b61848 100644
--- a/auth_providers/BUILD.gn
+++ b/auth_providers/BUILD.gn
@@ -26,6 +26,5 @@
"//third_party/googletest:gtest_main",
"//topaz/auth_providers/google:unittests",
"//topaz/auth_providers/oauth:unittests",
- "//topaz/auth_providers/spotify:unittests",
]
}
diff --git a/auth_providers/spotify/BUILD.gn b/auth_providers/spotify/BUILD.gn
deleted file mode 100644
index 7813fd6..0000000
--- a/auth_providers/spotify/BUILD.gn
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright 2018 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/package.gni")
-
-executable("bin") {
- output_name = "spotify_auth_provider"
-
- sources = [
- "main.cc",
- ]
-
- public_deps = [
- "//zircon/public/lib/fit",
- ]
-
- deps = [
- ":lib",
- "//sdk/fidl/fuchsia.auth",
- "//garnet/public/lib/component/cpp",
- "//sdk/lib/fidl/cpp",
- "//garnet/public/lib/fsl",
- "//garnet/public/lib/fxl",
- "//garnet/public/lib/network_wrapper",
- "//zircon/public/lib/async-loop-cpp",
- "//zircon/public/lib/trace-provider",
- ]
-}
-
-source_set("lib") {
- sources = [
- "constants.h",
- "factory_impl.cc",
- "factory_impl.h",
- "spotify_auth_provider_impl.cc",
- "spotify_auth_provider_impl.h",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.net.oldhttp",
- "//garnet/public/lib/svc/cpp",
- "//peridot/lib/rapidjson",
- "//third_party/rapidjson",
- "//topaz/auth_providers/oauth",
- ]
-
- public_deps = [
- "//sdk/fidl/fuchsia.auth",
- "//sdk/fidl/fuchsia.ui.app",
- "//garnet/public/lib/callback",
- "//garnet/public/lib/component/cpp",
- "//sdk/lib/fidl/cpp",
- "//garnet/public/lib/fxl",
- "//garnet/public/lib/network_wrapper",
- "//zircon/public/lib/fit",
- "//zircon/public/lib/zx",
- ]
-}
-
-source_set("unittests") {
- testonly = true
-
- sources = [
- "factory_impl_unittest.cc",
- "spotify_auth_provider_impl_unittest.cc",
- ]
-
- deps = [
- ":lib",
- "//sdk/fidl/fuchsia.auth",
- "//sdk/lib/fidl/cpp",
- "//garnet/public/lib/fxl:fxl_printers",
- "//garnet/public/lib/gtest:gtest",
- "//garnet/public/lib/network_wrapper:fake",
- "//peridot/lib/rapidjson",
- "//third_party/googletest:gtest_main",
- ]
-}
-
-package("spotify_auth_provider") {
- deprecated_system_image = true
-
- deps = [
- ":bin",
- ]
-
- binaries = [
- {
- name = "spotify_auth_provider"
- },
- ]
-}
diff --git a/auth_providers/spotify/constants.h b/auth_providers/spotify/constants.h
deleted file mode 100644
index 68288e9..0000000
--- a/auth_providers/spotify/constants.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_AUTH_PROVIDERS_SPOTIFY_CONSTANTS_H_
-#define TOPAZ_AUTH_PROVIDERS_SPOTIFY_CONSTANTS_H_
-
-#include <initializer_list>
-
-namespace spotify_auth_provider {
-
-constexpr char kSpotifyOAuthAuthEndpoint[] =
- "https://accounts.spotify.com/authorize";
-constexpr char kSpotifyOAuthTokenEndpoint[] =
- "https://accounts.spotify.com/api/token";
-// Spotify doesn't provide a programmatic way to revoke access. Instead, users
-// revoke access manually by visting this url.
-constexpr char kSpotifyRevokeTokenEndpoint[] =
- "https://www.spotify.com/account/";
-constexpr char kSpotifyPeopleGetEndpoint[] =
- "https://api.spotify.com/v1/me";
-constexpr char kRedirectUri[] = "com.spotify.fuchsia.auth:/oauth2redirect";
-constexpr char kWebViewUrl[] = "web_view";
-
-// Default scopes
-constexpr auto kScopes = {
- "user-read-private",
- "user-read-email",
- "user-read-birthdate",
- "playlist-read-private",
- "playlist-modify-private",
- "playlist-modify-public",
- "playlist-read-collaborative",
- "user-top-read",
- "user-read-recently-played"
-};
-
-} // namespace spotify_auth_provider
-
-#endif // TOPAZ_AUTH_PROVIDERS_SPOTIFY_CONSTANTS_H_
-
-
diff --git a/auth_providers/spotify/factory_impl.cc b/auth_providers/spotify/factory_impl.cc
deleted file mode 100644
index 7c1df27..0000000
--- a/auth_providers/spotify/factory_impl.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/auth_providers/spotify/factory_impl.h"
-
-namespace spotify_auth_provider {
-
-FactoryImpl::FactoryImpl(component::StartupContext* context,
- network_wrapper::NetworkWrapper* network_wrapper)
- : context_(context), network_wrapper_(network_wrapper) {
- FXL_DCHECK(context_);
- FXL_DCHECK(network_wrapper_);
-}
-
-FactoryImpl::~FactoryImpl() {}
-
-void FactoryImpl::Bind(
- fidl::InterfaceRequest<fuchsia::auth::AuthProviderFactory> request) {
- factory_bindings_.AddBinding(this, std::move(request));
-}
-
-void FactoryImpl::GetAuthProvider(
- fidl::InterfaceRequest<fuchsia::auth::AuthProvider> auth_provider,
- GetAuthProviderCallback callback) {
- providers_.emplace(context_, network_wrapper_, std::move(auth_provider));
- callback(fuchsia::auth::AuthProviderStatus::OK);
-}
-
-} // namespace spotify_auth_provider
diff --git a/auth_providers/spotify/factory_impl.h b/auth_providers/spotify/factory_impl.h
deleted file mode 100644
index 0074499..0000000
--- a/auth_providers/spotify/factory_impl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_AUTH_PROVIDERS_SPOTIFY_FACTORY_IMPL_H_
-#define TOPAZ_AUTH_PROVIDERS_SPOTIFY_FACTORY_IMPL_H_
-
-#include <fuchsia/auth/cpp/fidl.h>
-
-#include "lib/callback/auto_cleanable.h"
-#include "lib/fxl/functional/closure.h"
-#include "lib/fxl/macros.h"
-#include "lib/network_wrapper/network_wrapper.h"
-#include "topaz/auth_providers/spotify/spotify_auth_provider_impl.h"
-
-namespace spotify_auth_provider {
-
-using fuchsia::auth::AuthProvider;
-using fuchsia::auth::AuthProviderFactory;
-
-class FactoryImpl : public fuchsia::auth::AuthProviderFactory {
- public:
- FactoryImpl(component::StartupContext* context,
- network_wrapper::NetworkWrapper* network_wrapper);
-
- ~FactoryImpl() override;
-
- void Bind(fidl::InterfaceRequest<AuthProviderFactory> request);
-
- private:
- // Factory:
- void GetAuthProvider(fidl::InterfaceRequest<AuthProvider> auth_provider,
- GetAuthProviderCallback callback) override;
-
- component::StartupContext* const context_;
- network_wrapper::NetworkWrapper* const network_wrapper_;
-
- callback::AutoCleanableSet<SpotifyAuthProviderImpl> providers_;
-
- fidl::BindingSet<AuthProviderFactory> factory_bindings_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
-};
-
-} // namespace spotify_auth_provider
-
-#endif // TOPAZ_AUTH_PROVIDERS_SPOTIFY_FACTORY_IMPL_H_
diff --git a/auth_providers/spotify/factory_impl_unittest.cc b/auth_providers/spotify/factory_impl_unittest.cc
deleted file mode 100644
index a745757..0000000
--- a/auth_providers/spotify/factory_impl_unittest.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/auth_providers/spotify/factory_impl.h"
-
-#include "lib/callback/capture.h"
-#include "lib/callback/set_when_called.h"
-#include "lib/fidl/cpp/binding.h"
-#include "lib/fxl/macros.h"
-#include "lib/gtest/test_loop_fixture.h"
-#include "lib/network_wrapper/fake_network_wrapper.h"
-
-namespace spotify_auth_provider {
-
-class SpotifyFactoryImplTest : public gtest::TestLoopFixture {
- public:
- SpotifyFactoryImplTest()
- : network_wrapper_(dispatcher()),
- context_(component::StartupContext::CreateFromStartupInfo().get()),
- factory_impl_(context_, &network_wrapper_) {
- factory_impl_.Bind(factory_.NewRequest());
- }
-
- ~SpotifyFactoryImplTest() override {}
-
- protected:
- network_wrapper::FakeNetworkWrapper network_wrapper_;
- component::StartupContext* context_;
- fuchsia::auth::AuthProviderPtr auth_provider_;
- fuchsia::auth::AuthProviderFactoryPtr factory_;
-
- FactoryImpl factory_impl_;
-
- private:
- FXL_DISALLOW_COPY_AND_ASSIGN(SpotifyFactoryImplTest);
-};
-
-TEST_F(SpotifyFactoryImplTest, GetAuthProvider) {
- fuchsia::auth::AuthProviderStatus status;
- auth_provider_.Unbind();
- bool callback_called = false;
- factory_->GetAuthProvider(
- auth_provider_.NewRequest(),
- callback::Capture(callback::SetWhenCalled(&callback_called), &status));
- RunLoopUntilIdle();
- EXPECT_TRUE(callback_called);
- EXPECT_EQ(fuchsia::auth::AuthProviderStatus::OK, status);
-}
-
-} // namespace spotify_auth_provider
diff --git a/auth_providers/spotify/main.cc b/auth_providers/spotify/main.cc
deleted file mode 100644
index 074e9db..0000000
--- a/auth_providers/spotify/main.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <trace-provider/provider.h>
-#include <memory>
-
-#include <fuchsia/auth/cpp/fidl.h>
-#include <lib/async-loop/cpp/loop.h>
-
-#include "lib/component/cpp/startup_context.h"
-#include "lib/backoff/exponential_backoff.h"
-#include "lib/fidl/cpp/binding_set.h"
-#include "lib/fidl/cpp/interface_request.h"
-#include "lib/fsl/vmo/strings.h"
-#include "lib/fxl/command_line.h"
-#include "lib/fxl/log_settings_command_line.h"
-#include "lib/network_wrapper/network_wrapper_impl.h"
-#include "topaz/auth_providers/spotify/factory_impl.h"
-
-namespace {
-
-namespace http = ::fuchsia::net::oldhttp;
-
-using fuchsia::auth::AuthProviderFactory;
-
-class SpotifyAuthProviderApp {
- public:
- SpotifyAuthProviderApp()
- : loop_(&kAsyncLoopConfigAttachToThread),
- startup_context_(component::StartupContext::CreateFromStartupInfo()),
- trace_provider_(loop_.dispatcher()),
- network_wrapper_(
- loop_.dispatcher(), std::make_unique<backoff::ExponentialBackoff>(),
- [this] {
- return startup_context_
- ->ConnectToEnvironmentService<http::HttpService>();
- }),
- factory_impl_(startup_context_.get(), &network_wrapper_) {
- FXL_DCHECK(startup_context_);
- }
-
- ~SpotifyAuthProviderApp() { loop_.Quit(); }
-
- void Run() {
- startup_context_->outgoing().AddPublicService<AuthProviderFactory>(
- [this](fidl::InterfaceRequest<AuthProviderFactory> request) {
- factory_impl_.Bind(std::move(request));
- });
- loop_.Run();
- }
-
- private:
- async::Loop loop_;
- std::unique_ptr<component::StartupContext> startup_context_;
- trace::TraceProvider trace_provider_;
- network_wrapper::NetworkWrapperImpl network_wrapper_;
-
- spotify_auth_provider::FactoryImpl factory_impl_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(SpotifyAuthProviderApp);
-};
-
-} // namespace
-
-int main(int argc, const char** argv) {
- auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
- if (!fxl::SetLogSettingsFromCommandLine(command_line)) {
- return 1;
- }
-
- SpotifyAuthProviderApp app;
- app.Run();
-
- return 0;
-}
diff --git a/auth_providers/spotify/spotify_auth_provider_impl.cc b/auth_providers/spotify/spotify_auth_provider_impl.cc
deleted file mode 100644
index f7dc734..0000000
--- a/auth_providers/spotify/spotify_auth_provider_impl.cc
+++ /dev/null
@@ -1,214 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/auth_providers/spotify/spotify_auth_provider_impl.h"
-
-#include <fuchsia/net/oldhttp/cpp/fidl.h>
-#include <fuchsia/ui/app/cpp/fidl.h>
-#include <lib/fit/function.h>
-
-#include "lib/component/cpp/connect.h"
-#include "lib/component/cpp/startup_context.h"
-#include "lib/fidl/cpp/interface_request.h"
-#include "lib/fxl/logging.h"
-#include "lib/fxl/strings/join_strings.h"
-#include "lib/svc/cpp/services.h"
-#include "peridot/lib/rapidjson/rapidjson.h"
-#include "rapidjson/document.h"
-#include "topaz/auth_providers/oauth/oauth_request_builder.h"
-#include "topaz/auth_providers/oauth/oauth_response.h"
-#include "topaz/auth_providers/spotify/constants.h"
-
-namespace spotify_auth_provider {
-
-namespace http = ::fuchsia::net::oldhttp;
-
-using auth_providers::oauth::OAuthRequestBuilder;
-using auth_providers::oauth::ParseOAuthResponse;
-using fuchsia::auth::AssertionJWTParams;
-using fuchsia::auth::AttestationJWTParams;
-using fuchsia::auth::AuthProviderStatus;
-using fuchsia::auth::AuthTokenPtr;
-using modular::JsonValueToPrettyString;
-
-SpotifyAuthProviderImpl::SpotifyAuthProviderImpl(
- component::StartupContext* context,
- network_wrapper::NetworkWrapper* network_wrapper,
- fidl::InterfaceRequest<fuchsia::auth::AuthProvider> request)
- : network_wrapper_(network_wrapper),
- binding_(this, std::move(request)) {
- FXL_DCHECK(network_wrapper_);
-
- // The class shuts down when the client connection is disconnected.
- binding_.set_error_handler([this](zx_status_t status) {
- if (on_empty_) {
- on_empty_();
- }
- });
-}
-
-SpotifyAuthProviderImpl::~SpotifyAuthProviderImpl() {}
-
-void SpotifyAuthProviderImpl::GetPersistentCredential(
- fidl::InterfaceHandle<fuchsia::auth::AuthenticationUIContext>
- auth_ui_context,
- const fidl::StringPtr user_profile_id,
- GetPersistentCredentialCallback callback) {
- FXL_DCHECK(auth_ui_context);
- get_persistent_credential_callback_ = std::move(callback);
-
- // TODO(jsankey): Teach this code how to hold a chromium based web view.
-}
-
-void SpotifyAuthProviderImpl::GetAppAccessToken(
- const std::string credential, const fidl::StringPtr app_client_id,
- const std::vector<std::string> app_scopes,
- GetAppAccessTokenCallback callback) {
- if (credential.empty()) {
- callback(AuthProviderStatus::BAD_REQUEST, nullptr);
- return;
- }
-
- if (app_client_id->empty()) {
- callback(AuthProviderStatus::BAD_REQUEST, nullptr);
- return;
- }
-
- auto request = OAuthRequestBuilder(kSpotifyOAuthTokenEndpoint, "POST")
- .SetUrlEncodedBody("refresh_token=" + credential +
- "&client_id=" + app_client_id.get() +
- "&grant_type=refresh_token");
-
- auto request_factory = [request = std::move(request)] {
- return request.Build();
- };
-
- Request(std::move(request_factory), [callback = std::move(callback)](
- http::URLResponse response) {
- auto oauth_response = ParseOAuthResponse(std::move(response));
- if (oauth_response.status != AuthProviderStatus::OK) {
- FXL_VLOG(1) << "Got error: " << oauth_response.error_description;
- FXL_VLOG(1) << "Got response: "
- << JsonValueToPrettyString(oauth_response.json_response);
- callback(oauth_response.status, nullptr);
- return;
- }
-
- AuthTokenPtr access_token = fuchsia::auth::AuthToken::New();
- access_token->token_type = fuchsia::auth::TokenType::ACCESS_TOKEN;
- access_token->token =
- oauth_response.json_response["access_token"].GetString();
- access_token->expires_in =
- oauth_response.json_response["expires_in"].GetUint64();
-
- callback(AuthProviderStatus::OK, std::move(access_token));
- });
-}
-
-void SpotifyAuthProviderImpl::GetAppIdToken(const std::string credential,
- const fidl::StringPtr audience,
- GetAppIdTokenCallback callback) {
- // Id Tokens are not supported by Spotify.
- callback(AuthProviderStatus::BAD_REQUEST, nullptr);
-}
-
-void SpotifyAuthProviderImpl::GetAppFirebaseToken(
- const std::string id_token, const std::string firebase_api_key,
- GetAppFirebaseTokenCallback callback) {
- // Firebase Token doesn't exist for Spotify.
- callback(AuthProviderStatus::BAD_REQUEST, nullptr);
-}
-
-void SpotifyAuthProviderImpl::RevokeAppOrPersistentCredential(
- const std::string credential,
- RevokeAppOrPersistentCredentialCallback callback) {
- // There is no programmatic way to revoke tokens. Instead, Spotify users have
- // to manually revoke access from this page here:
- // <https://www.spotify.com/account/>
- callback(AuthProviderStatus::BAD_REQUEST);
-}
-
-void SpotifyAuthProviderImpl::GetPersistentCredentialFromAttestationJWT(
- fidl::InterfaceHandle<AttestationSigner> attestation_signer,
- AttestationJWTParams jwt_params,
- fidl::InterfaceHandle<AuthenticationUIContext> auth_ui_context,
- fidl::StringPtr user_profile_id,
- GetPersistentCredentialFromAttestationJWTCallback callback) {
- // Remote attestation flow not supported.
- callback(AuthProviderStatus::BAD_REQUEST, nullptr, nullptr, nullptr, nullptr);
-}
-
-void SpotifyAuthProviderImpl::GetAppAccessTokenFromAssertionJWT(
- fidl::InterfaceHandle<AttestationSigner> attestation_signer,
- AssertionJWTParams jwt_params, std::string credential,
- const std::vector<std::string> app_scopes,
- GetAppAccessTokenFromAssertionJWTCallback callback) {
- // Remote attestation flow not supported.
- callback(AuthProviderStatus::BAD_REQUEST, nullptr, nullptr, nullptr);
-}
-
-void SpotifyAuthProviderImpl::GetUserProfile(
- const fidl::StringPtr credential, const fidl::StringPtr access_token) {
- FXL_DCHECK(credential.get().size() > 0);
- FXL_DCHECK(access_token.get().size() > 0);
-
- auto request = OAuthRequestBuilder(kSpotifyPeopleGetEndpoint, "GET")
- .SetAuthorizationHeader(access_token.get());
-
- auto request_factory = [request = std::move(request)] {
- return request.Build();
- };
-
- Request(std::move(request_factory), [this,
- credential](http::URLResponse response) {
- fuchsia::auth::UserProfileInfoPtr user_profile_info =
- fuchsia::auth::UserProfileInfo::New();
-
- auto oauth_response = ParseOAuthResponse(std::move(response));
- if (oauth_response.status != AuthProviderStatus::OK) {
- FXL_VLOG(1) << "Got error: " << oauth_response.error_description;
- FXL_VLOG(1) << "Got response: "
- << JsonValueToPrettyString(oauth_response.json_response);
-
- get_persistent_credential_callback_(oauth_response.status, credential,
- std::move(user_profile_info));
- return;
- }
-
- if (oauth_response.json_response.HasMember("id")) {
- user_profile_info->id = oauth_response.json_response["id"].GetString();
- }
-
- if (oauth_response.json_response.HasMember("displayName")) {
- user_profile_info->display_name =
- oauth_response.json_response["displayName"].GetString();
- }
-
- if (oauth_response.json_response.HasMember("url")) {
- user_profile_info->url = oauth_response.json_response["url"].GetString();
- }
-
- if (oauth_response.json_response.HasMember("image")) {
- user_profile_info->image_url =
- oauth_response.json_response["image"]["url"].GetString();
- }
-
- get_persistent_credential_callback_(oauth_response.status, credential,
- std::move(user_profile_info));
- });
-}
-
-zx::eventpair SpotifyAuthProviderImpl::SetupChromium() {
- // TODO(jsankey): Implement.
- return {};
-}
-
-void SpotifyAuthProviderImpl::Request(
- fit::function<http::URLRequest()> request_factory,
- fit::function<void(http::URLResponse response)> callback) {
- requests_.emplace(network_wrapper_->Request(std::move(request_factory),
- std::move(callback)));
-}
-
-} // namespace spotify_auth_provider
diff --git a/auth_providers/spotify/spotify_auth_provider_impl.h b/auth_providers/spotify/spotify_auth_provider_impl.h
deleted file mode 100644
index 3935471..0000000
--- a/auth_providers/spotify/spotify_auth_provider_impl.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This application serves as the Spotify Auth provider for generating OAuth
-// credentials to talk to Spotify Api backends. This application implements
-// |auth_provider.fidl| interface and is typically invoked by the Token Manager
-// service in Garnet layer.
-
-#ifndef TOPAZ_AUTH_PROVIDERS_SPOTIFY_SPOTIFY_AUTH_PROVIDER_IMPL_H_
-#define TOPAZ_AUTH_PROVIDERS_SPOTIFY_SPOTIFY_AUTH_PROVIDER_IMPL_H_
-
-#include <fuchsia/auth/cpp/fidl.h>
-#include <lib/fit/function.h>
-#include <lib/zx/eventpair.h>
-
-#include "lib/callback/cancellable.h"
-#include "lib/component/cpp/startup_context.h"
-#include "lib/fidl/cpp/binding.h"
-#include "lib/fxl/macros.h"
-#include "lib/network_wrapper/network_wrapper.h"
-
-namespace spotify_auth_provider {
-
-using fuchsia::auth::AssertionJWTParams;
-using fuchsia::auth::AttestationJWTParams;
-using fuchsia::auth::AttestationSigner;
-using fuchsia::auth::AuthenticationUIContext;
-
-class SpotifyAuthProviderImpl : public fuchsia::auth::AuthProvider {
- public:
- SpotifyAuthProviderImpl(
- component::StartupContext* context,
- network_wrapper::NetworkWrapper* network_wrapper,
- fidl::InterfaceRequest<fuchsia::auth::AuthProvider> request);
-
- ~SpotifyAuthProviderImpl() override;
-
- void set_on_empty(fit::closure on_empty) { on_empty_ = std::move(on_empty); }
-
- private:
- // |AuthProvider|
- void GetPersistentCredential(
- fidl::InterfaceHandle<fuchsia::auth::AuthenticationUIContext>
- auth_ui_context,
- const fidl::StringPtr user_profile_id,
- GetPersistentCredentialCallback callback) override;
-
- // |AuthProvider|
- void GetAppAccessToken(const std::string credential,
- const fidl::StringPtr app_client_id,
- const std::vector<std::string> app_scopes,
- GetAppAccessTokenCallback callback) override;
-
- // |AuthProvider|
- void GetAppIdToken(const std::string credential,
- const fidl::StringPtr audience,
- GetAppIdTokenCallback callback) override;
-
- // |AuthProvider|
- void GetAppFirebaseToken(const std::string id_token,
- const std::string firebase_api_key,
- GetAppFirebaseTokenCallback callback) override;
-
- // |AuthProvider|
- void RevokeAppOrPersistentCredential(
- const std::string credential,
- RevokeAppOrPersistentCredentialCallback callback) override;
-
- // |AuthProvider|
- void GetPersistentCredentialFromAttestationJWT(
- fidl::InterfaceHandle<AttestationSigner> attestation_signer,
- AttestationJWTParams jwt_params,
- fidl::InterfaceHandle<AuthenticationUIContext> auth_ui_context,
- fidl::StringPtr user_profile_id,
- GetPersistentCredentialFromAttestationJWTCallback callback) override;
-
- // |AuthProvider|
- void GetAppAccessTokenFromAssertionJWT(
- fidl::InterfaceHandle<AttestationSigner> attestation_signer,
- AssertionJWTParams jwt_params, const std::string credential,
- const std::vector<std::string> app_scopes,
- GetAppAccessTokenFromAssertionJWTCallback callback) override;
-
- void GetUserProfile(const fidl::StringPtr credential,
- const fidl::StringPtr access_token);
-
- zx::eventpair SetupChromium();
-
- void Request(
- fit::function<::fuchsia::net::oldhttp::URLRequest()> request_factory,
- fit::function<void(::fuchsia::net::oldhttp::URLResponse response)>
- callback);
-
- fuchsia::auth::AuthenticationUIContextPtr auth_ui_context_;
- network_wrapper::NetworkWrapper* const network_wrapper_;
- GetPersistentCredentialCallback get_persistent_credential_callback_;
-
- fidl::Binding<fuchsia::auth::AuthProvider> binding_;
- callback::CancellableContainer requests_;
-
- fit::closure on_empty_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(SpotifyAuthProviderImpl);
-};
-
-} // namespace spotify_auth_provider
-
-#endif // TOPAZ_AUTH_PROVIDERS_SPOTIFY_SPOTIFY_AUTH_PROVIDER_IMPL_H_
diff --git a/auth_providers/spotify/spotify_auth_provider_impl_unittest.cc b/auth_providers/spotify/spotify_auth_provider_impl_unittest.cc
deleted file mode 100644
index ecfcaf2..0000000
--- a/auth_providers/spotify/spotify_auth_provider_impl_unittest.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/auth_providers/spotify/spotify_auth_provider_impl.h"
-
-#include "lib/callback/capture.h"
-#include "lib/callback/set_when_called.h"
-#include "lib/fidl/cpp/binding.h"
-#include "lib/fxl/macros.h"
-#include "lib/gtest/test_loop_fixture.h"
-#include "lib/network_wrapper/fake_network_wrapper.h"
-#include "peridot/lib/rapidjson/rapidjson.h"
-
-namespace spotify_auth_provider {
-namespace {
-
-using fuchsia::auth::AuthProviderStatus;
-using fuchsia::auth::AuthTokenPtr;
-
-class SpotifyAuthProviderImplTest : public gtest::TestLoopFixture {
- public:
- SpotifyAuthProviderImplTest()
- : network_wrapper_(dispatcher()),
- context_(component::StartupContext::CreateFromStartupInfo().get()),
- spotify_auth_provider_impl_(context_, &network_wrapper_,
- auth_provider_.NewRequest()) {}
-
- ~SpotifyAuthProviderImplTest() override {}
-
- protected:
- network_wrapper::FakeNetworkWrapper network_wrapper_;
- component::StartupContext* context_;
- fuchsia::auth::AuthProviderPtr auth_provider_;
- SpotifyAuthProviderImpl spotify_auth_provider_impl_;
-
- private:
- FXL_DISALLOW_COPY_AND_ASSIGN(SpotifyAuthProviderImplTest);
-};
-
-TEST_F(SpotifyAuthProviderImplTest, EmptyWhenClientDisconnected) {
- bool on_empty_called = false;
- spotify_auth_provider_impl_.set_on_empty([this, &on_empty_called] {
- on_empty_called = true;
- QuitLoop();
- });
- auth_provider_.Unbind();
- RunLoopUntilIdle();
- EXPECT_TRUE(on_empty_called);
-}
-
-TEST_F(SpotifyAuthProviderImplTest, GetAppAccessTokenSuccess) {
- bool callback_called = false;
- auto status = AuthProviderStatus::INTERNAL_ERROR;
- AuthTokenPtr access_token;
- std::vector<std::string> scopes;
- scopes.push_back("http://spotifyapis.test.com/scope1");
- scopes.push_back("http://spotifyapis.test.com/scope2");
-
- rapidjson::Document ok_response;
- ok_response.Parse("{\"access_token\":\"at_token\", \"expires_in\":3600}");
- network_wrapper_.SetStringResponse(
- modular::JsonValueToPrettyString(ok_response), 200);
-
- auth_provider_->GetAppAccessToken(
- "credential", "app_client_id", std::move(scopes),
- callback::Capture(callback::SetWhenCalled(&callback_called), &status,
- &access_token));
-
- RunLoopUntilIdle();
- EXPECT_TRUE(callback_called);
- EXPECT_EQ(status, AuthProviderStatus::OK);
- EXPECT_FALSE(access_token == NULL);
- EXPECT_EQ(access_token->token_type, fuchsia::auth::TokenType::ACCESS_TOKEN);
- EXPECT_EQ(access_token->token, "at_token");
- EXPECT_EQ(access_token->expires_in, 3600u);
-}
-
-TEST_F(SpotifyAuthProviderImplTest, GetAppAccessTokenError) {
- bool callback_called = false;
- auto status = AuthProviderStatus::INTERNAL_ERROR;
- AuthTokenPtr access_token;
- std::vector<std::string> scopes;
- scopes.push_back("http://spotifyapis.test.com/scope1");
- scopes.push_back("http://spotifyapis.test.com/scope2");
-
- rapidjson::Document ok_response;
- ok_response.Parse("{\"error\":\"invalid_client\"}");
- network_wrapper_.SetStringResponse(
- modular::JsonValueToPrettyString(ok_response), 401);
-
- auth_provider_->GetAppAccessToken(
- "credential", "invalid_client_id", std::move(scopes),
- callback::Capture(callback::SetWhenCalled(&callback_called), &status,
- &access_token));
-
- RunLoopUntilIdle();
- EXPECT_TRUE(callback_called);
- EXPECT_EQ(status, AuthProviderStatus::OAUTH_SERVER_ERROR);
- EXPECT_TRUE(access_token == NULL);
-}
-
-TEST_F(SpotifyAuthProviderImplTest, GetAppIdTokenUnsupported) {
- bool callback_called = false;
- auto status = AuthProviderStatus::INTERNAL_ERROR;
- AuthTokenPtr id_token;
-
- auth_provider_->GetAppIdToken(
- "", "",
- callback::Capture(callback::SetWhenCalled(&callback_called), &status,
- &id_token));
-
- RunLoopUntilIdle();
- EXPECT_TRUE(callback_called);
- EXPECT_EQ(status, AuthProviderStatus::BAD_REQUEST);
- EXPECT_TRUE(id_token == NULL);
-}
-
-TEST_F(SpotifyAuthProviderImplTest, GetAppFirebaseTokenUnsupported) {
- bool callback_called = false;
- auto status = AuthProviderStatus::INTERNAL_ERROR;
- fuchsia::auth::FirebaseTokenPtr fb_token;
-
- auth_provider_->GetAppFirebaseToken(
- "", "",
- callback::Capture(callback::SetWhenCalled(&callback_called), &status,
- &fb_token));
-
- RunLoopUntilIdle();
- EXPECT_TRUE(callback_called);
- EXPECT_EQ(status, AuthProviderStatus::BAD_REQUEST);
- EXPECT_TRUE(fb_token == NULL);
-}
-
-TEST_F(SpotifyAuthProviderImplTest,
- RevokeAppOrPersistentCredentialUnsupported) {
- bool callback_called = false;
- auto status = AuthProviderStatus::INTERNAL_ERROR;
-
- auth_provider_->RevokeAppOrPersistentCredential(
- "",
- callback::Capture(callback::SetWhenCalled(&callback_called), &status));
-
- RunLoopUntilIdle();
- EXPECT_TRUE(callback_called);
- EXPECT_EQ(status, AuthProviderStatus::BAD_REQUEST);
-}
-
-} // namespace
-} // namespace spotify_auth_provider
diff --git a/packages/prod/all b/packages/prod/all
index f595692..29f0ad3 100644
--- a/packages/prod/all
+++ b/packages/prod/all
@@ -25,7 +25,6 @@
"topaz/packages/prod/modules_index",
"topaz/packages/prod/mondrian",
"topaz/packages/prod/skottie_viewer",
- "topaz/packages/prod/spotify_auth_provider",
"topaz/packages/prod/system_dashboard",
"topaz/packages/prod/term",
"topaz/packages/prod/text_input_mod",
diff --git a/packages/prod/spotify_auth_provider b/packages/prod/spotify_auth_provider
deleted file mode 100644
index 8bc63b6..0000000
--- a/packages/prod/spotify_auth_provider
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "packages": [
- "//topaz/auth_providers/spotify:spotify_auth_provider"
- ]
-}