This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "feat: admin endpoint to query domains by provider_url"
- Loading branch information
Showing
9 changed files
with
268 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
poppy/storage/cassandra/migrations/010_provider_url_domain.cql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE provider_url_domain ( | ||
provider_url VARCHAR, | ||
domain_name VARCHAR, | ||
PRIMARY KEY (provider_url, domain_name)); | ||
|
||
|
||
--//@UNDO | ||
|
||
DROP TABLE provider_url_domain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
tests/functional/transport/pecan/controllers/test_get_domain_by_provider_url.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright (c) 2015 Rackspace, Inc. | ||
# | ||
# Licensed 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. | ||
|
||
import uuid | ||
|
||
import ddt | ||
from hypothesis import given | ||
from hypothesis import strategies | ||
import mock | ||
import six | ||
|
||
from poppy.manager.default.services import DefaultServicesController | ||
|
||
from tests.functional.transport.pecan import base | ||
|
||
|
||
@ddt.ddt | ||
class TestGetDomainsbyProviderurl(base.FunctionalTest): | ||
|
||
def test_get_domains_provider_url_no_queryparam(self): | ||
# no provider_url field | ||
url = '/v1.0/admin/domains' | ||
response = self.app.get(url, | ||
headers={'Content-Type': | ||
'application/json', | ||
'X-Project-ID': | ||
str(uuid.uuid4())}, | ||
expect_errors=True) | ||
self.assertEqual(response.status_code, 400) | ||
|
||
@given(strategies.text()) | ||
def test_get_domains_provider_url_invalid_queryparam(self, | ||
provider_url): | ||
# invalid provider_url field | ||
try: | ||
# NOTE(TheSriram): Py3k Hack | ||
if six.PY3 and type(provider_url) == str: | ||
provider_url = provider_url.encode('utf-8') | ||
url = '/v1.0/admin/domains?' \ | ||
'provider_url={0}'.format(provider_url) | ||
|
||
else: | ||
url = '/v1.0/admin/domains?provider_url=%s' \ | ||
% provider_url.decode('utf-8') | ||
except (UnicodeDecodeError, UnicodeEncodeError): | ||
pass | ||
else: | ||
response = self.app.get(url, | ||
headers={'Content-Type': | ||
'application/json', | ||
'X-Project-ID': | ||
str(uuid.uuid4())}, | ||
expect_errors=True) | ||
|
||
self.assertEqual(response.status_code, 400) | ||
|
||
@ddt.data('provider.com.extension.provideredge.net', | ||
'secure.shard.domain.com.provideredge.net', | ||
'www.domain.com.provideredge.net') | ||
def test_get_domains_provider_url_valid_queryparam(self, provider_url): | ||
# valid provider_url | ||
with mock.patch.object(DefaultServicesController, | ||
'get_domains_by_provider_url'): | ||
response = self.app.get('/v1.0/admin/domains' | ||
'?provider_url={0}'.format(provider_url), | ||
headers={'Content-Type': | ||
'application/json', | ||
'X-Project-ID': | ||
str(uuid.uuid4())}) | ||
|
||
self.assertEqual(response.status_code, 200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"provider_details": | ||
{ | ||
"MaxCDN": "{\"id\": 11942, \"access_urls\": [\"mypullzone.netdata.com\"], \"domains_certificate_status\":{\"mypullzone.com\": \"failed\"} }", | ||
"Mock": "{\"id\": 73242, \"access_urls\": [\"mycdn.mock.com\"], \"domains_certificate_status\":{\"mycdn.mock.com\": \"deployed\"} }", | ||
"CloudFront": "{\"id\": \"5ABC892\", \"access_urls\": [\"cf123.cloudcf.com\"]}", | ||
"Fastly": "{\"id\": 3488, \"access_urls\": [\"mockcf123.fastly.prod.com\"], \"domains_certificate_status\":{\"mockcf123.com\": \"create_in_progress\"}}" | ||
"MaxCDN": "{\"id\": 11942, \"access_urls\": [{\"provider_url\": \"maxcdn.provider.com\", \"domain\": \"xk.cd\"}], \"domains_certificate_status\":{\"mypullzone.com\": \"failed\"} }", | ||
"Mock": "{\"id\": 73242, \"access_urls\": [{\"provider_url\": \"mycdn.mock.com\", \"domain\": \"xk.cd\"}], \"domains_certificate_status\":{\"mycdn.mock.com\": \"deployed\"} }", | ||
"CloudFront": "{\"id\": \"5ABC892\", \"access_urls\": [{\"provider_url\": \"cloudfront.provider.com\", \"domain\": \"xk.cd\"}]}", | ||
"Fastly": "{\"id\": 3488, \"access_urls\": [{\"provider_url\": \"fastly.provider.com\", \"domain\": \"xk.cd\"}], \"domains_certificate_status\":{\"mockcf123.com\": \"create_in_progress\"}}" | ||
} | ||
} |
Oops, something went wrong.