Exemple #1
0
 def oauth2(self):
     return OAuth2(
         access_token_uri=
         "https://p-spring-cloud-services.uaa.sys.example.com/oauth/token",
         client_id="p.config-server-example-client-id",
         client_secret="EXAMPLE_SECRET",
     )
Exemple #2
0
 def configure_custom_client(self, MockRequests):
     custom_client = ConfigClient(
         address="http://localhost:8888/configuration", app_name="myapp")
     custom_oauth2 = OAuth2(
         access_token_uri="http://localhost/token",
         client_id="id",
         client_secret="secret",
     )
     return CF(oauth2=custom_oauth2, client=custom_client)
Exemple #3
0
 def test_custom_properties(self):
     oauth2 = OAuth2(
         access_token_uri='http://localhost/token',
         client_id='id',
         client_secret='secret'
     )
     client = ConfigClient(address='http://localhost', app_name='test_app')
     cf = CF(oauth2=oauth2, client=client)
     self.assertEqual(cf.client, client)
     self.assertEqual(cf.oauth2, oauth2)
Exemple #4
0
 def test_custom_properties(self, monkeypatch):
     monkeypatch.setattr(requests, "post", ResponseMock)
     oauth2 = OAuth2(
         access_token_uri="http://localhost/token",
         client_id="id",
         client_secret="secret",
     )
     client = ConfigClient(address="http://localhost", app_name="test_app")
     cf = CF(oauth2=oauth2, client=client)
     assert cf.client, client
     assert cf.oauth2, oauth2
Exemple #5
0
    def __attrs_post_init__(self) -> None:
        if not self.oauth2:
            self.oauth2 = OAuth2(
                access_token_uri=self.cfenv.configserver_access_token_uri(),
                client_id=self.cfenv.configserver_client_id(),
                client_secret=self.cfenv.configserver_client_secret())

        if not self.client:
            self.client = ConfigClient(address=self.cfenv.configserver_uri(),
                                       app_name=self.cfenv.application_name)
        self.oauth2.configure()
Exemple #6
0
 def configure_custom_client(self, MockRequests):
     custom_client = ConfigClient(
         address='http://localhost:8888/configuration',
         app_name='myapp'
     )
     custom_oauth2 = OAuth2(
         access_token_uri='http://localhost/token',
         client_id='id',
         client_secret='secret'
     )
     return CF(oauth2=custom_oauth2, client=custom_client)
Exemple #7
0
 def client_with_auth(self, monkeypatch, mocker):
     monkeypatch.setattr(requests, "post", conftest.response_mock_success)
     mocker.patch.object(requests, "get")
     requests.get.return_value = conftest.ResponseMock()
     return ConfigClient(
         app_name="test_app",
         oauth2=OAuth2(
             access_token_uri=
             "https://p-spring-cloud-services.uaa.sys.example.com/oauth/token",
             client_id="p-config-server-example-client-id",
             client_secret="EXAMPLE_SECRET",
         ),
     )
Exemple #8
0
    def __attrs_post_init__(self) -> None:
        if not self.oauth2:
            self.oauth2 = OAuth2(
                access_token_uri=self.cfenv.configserver_access_token_uri(),
                client_id=self.cfenv.configserver_client_id(),
                client_secret=self.cfenv.configserver_client_secret(),
            )

        if not self.client:
            self.client = ConfigClient(
                address=self.cfenv.configserver_uri(),
                app_name=self.cfenv.application_name,
                profile=self.cfenv.space_name.lower(),
                oauth2=self.oauth2,
            )
Exemple #9
0
 def setUp(self):
     self.oauth2 = OAuth2(
         access_token_uri='https://p-spring-cloud-services.uaa.sys.example.com/oauth/token',
         client_id='p-config-server-example-client-id',
         client_secret='EXAMPLE_SECRET'
     )