Beispiel #1
0
 def acquire(self, email, password, user_domain):
     device_id = id.id()
     data = {
         'email': email,
         'password': password,
         'user_domain': user_domain,
         'device_mac_address': device_id.mac_address,
         'device_name': device_id.name,
         'device_title': device_id.title,
     }
     url = urljoin(self.insider_config.get_redirect_api_url(), "/domain/acquire")
     response = requests.post(url, data)
     self.check_http_error(response)
     domain = convertible.from_json(response.text)
     self.domain_config.save(domain)
     return domain
Beispiel #2
0
    def test_link_success(self):
        config.footprints.append(('my-PC', footprint.footprint()))
        config.titles['my-PC'] = 'My PC'
        device_id = id.id()

        domain_config = get_domain_config(None)

        responses.add(responses.POST,
                      "http://api.domain.com/domain/acquire",
                      status=200,
                      body='{"user_domain": "boris", "update_token": "some_update_token"}',
                      content_type="application/json")

        insider_config = get_insider_config('domain.com', 'http://api.domain.com')
        dns = Dns(insider_config, domain_config, service_config=None, port_mapper=None, local_ip='127.0.0.1')
        result = dns.acquire('*****@*****.**', 'pass1234', 'boris')

        self.assertIsNotNone(result)
        self.assertEquals(result.user_domain, "boris")
        self.assertEquals(result.update_token, "some_update_token")

        expected_request_data = {
            "password": "******",
            "email": "*****@*****.**",
            "user_domain": "boris",
            'device_mac_address': device_id.mac_address,
            'device_name': device_id.name,
            'device_title': device_id.title,
        }
        # Need to assert all passed POST parameters
        # self.assertSingleRequest(convertible.to_json(expected_request_data))

        domain = domain_config.load()
        self.assertIsNotNone(domain)
        self.assertEquals(domain.user_domain, "boris")
        self.assertEquals(domain.update_token, "some_update_token")