Stores a Google Business API customer's signing information to be passed with service requests to Google's APIs.
Use GoogleSigned.AssignAllServices() method to attach the signing information to all outgoing requests, usually during App Startup.
 public void FromAppSettingsValue_should_fail(string value)
 {
     Assert.Throws <ArgumentException>(() => {
         var signingInstance = GoogleSigned.FromValueString(value);
         var actual          = signingInstance.GetSignedUri(BASE_URI);
     });
 }
        public void Api_Key_Signing()
        {
            var sign = new GoogleSigned("mykey");

            string signed = sign.GetSignedUri("http://a/dummy/server?a=b");

            Assert.AreEqual("http://a/dummy/server?a=b&key=mykey", signed);
        }
Beispiel #3
0
 /// <summary>
 /// Assigns the given SigningInstance to all services that can utilize it.  Note that some of the services do not currently use the signature method.
 /// </summary>
 /// <param name="signingInstance"></param>
 public static void AssignAllServices(GoogleSigned signingInstance)
 {
     S_universalSigningInstance = signingInstance;
     //Direction.DirectionService.SigningInstance = signingInstance;
     //DistanceMatrix.DistanceMatrixService.SigningInstance = signingInstance;
     //Elevation.ElevationService.SigningInstance = signingInstance;
     //Geocoding.GeocodingService.SigningInstance = signingInstance;
     //StaticMaps.StaticMapService.SigningInstance = signingInstance;
 }
Beispiel #4
0
 /// <summary>
 /// Assigns the given SigningInstance to all services that can utilize it.  Note that some of the services do not currently use the signature method.
 /// </summary>
 /// <param name="signingInstance"></param>
 public static void AssignAllServices(GoogleSigned signingInstance)
 {
     S_universalSigningInstance = signingInstance;
     //Direction.DirectionService.SigningInstance = signingInstance;
     //DistanceMatrix.DistanceMatrixService.SigningInstance = signingInstance;
     //Elevation.ElevationService.SigningInstance = signingInstance;
     //Geocoding.GeocodingService.SigningInstance = signingInstance;
     //StaticMaps.StaticMapService.SigningInstance = signingInstance;
 }
        public void FromAppSettingsValue_pass(string value, string expected)
        {
            //arrange

            //act
            var signingInstance = GoogleSigned.FromValueString(value);
            var actual          = signingInstance.GetSignedUri(BASE_URI);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void ctor_ApiKey_And_Signature()
        {
            //arrange
            string expected = BASE_URI + "&key=" + APIKEY + "&signature=ZSPqURu7BsGJ_XybwhRY4kk3Zhg=";

            //act
            GoogleSigned sign   = new GoogleSigned(APIKEY, SHARED_SECRET);
            string       actual = sign.GetSignedUri(BASE_URI);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void ctor_ApiKey()
        {
            //arrange
            string expected = BASE_URI + "&key=" + APIKEY;

            //act
            GoogleSigned sign   = new GoogleSigned(APIKEY);
            string       actual = sign.GetSignedUri(BASE_URI);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void ctor_ClientId_ForBusiness_Signed()
        {
            //arrange
            var expected = BASE_URI + "&client=" + CLIENT_ID + "&signature=uq9UYD8EJ2JIXvdNGkiMr5FsVdI=";

            //act
            var GoogleSigned = new GoogleSigned(CLIENT_ID, SHARED_SECRET, GoogleSignedType.Business);
            var actual       = GoogleSigned.GetSignedUri(BASE_URI);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Geocoding_Request_Signed_With_Private_Key()
        {
            var request = new GeocodingRequest
            {
                Address = "Stathern, UK"
            };

            GoogleSigned.AssignAllServices(GetRealSigningInstance());
            var response = new GeocodingService().GetResponse(request);

            Assert.AreEqual(ServiceResponseStatus.Ok, response.Status);
        }
        public void Private_Key_Signing()
        {
            GoogleSigned sign = GetGoogleSigned_TestInstance();

            var uri = "http://testserver/maps/api/outputType?sensor=false";

            uri += "client=" + sign.ClientId;

            string expected = "nEt2lIqwIuMkMia4OtJhsCc8cT0=";
            string actual   = sign.GetSignature(uri);

            Assert.AreEqual(expected, actual);
        }
        public void Geocoding_Request_Signed_With_Api_Key()
        {
            // Arrange
            var sign = new GoogleSigned("AIzaSyDV-0ftj1tsjfd6GnEbtbxwHXnv6iR3UEU");

            GoogleSigned.AssignAllServices(sign);

            var request = new GeocodingRequest
            {
                Address = "Stathern, UK"
            };

            // Act
            var response = new GeocodingService().GetResponse(request);

            // Assert
            Assert.AreEqual(ServiceResponseStatus.Ok, response.Status);
        }
Beispiel #12
0
 public void OneTimeTearDown()
 {
     GoogleSigned.AssignAllServices(null);
 }
Beispiel #13
0
 public void OneTimeSetUp()
 {
     TestingApiKey = SigningHelper.GetApiKey();
     GoogleSigned.AssignAllServices(TestingApiKey);
 }
		internal static void AssignSigningInstance(BaseSigningService serviceInstance, GoogleSigned signingInstance)
		{
			S_SigningInstances[serviceInstance.GetType()] = signingInstance;
		}
 /// <summary>
 /// Assigns the given SigningInstance to all services that can utilize it.  Note that some of the services do not currently use the signature method.
 /// </summary>
 /// <param name="signingInstance"></param>
 public static void AssignAllServices(GoogleSigned signingInstance)
 {
     S_universalSigningInstance = signingInstance;
 }
 internal static void AssignSigningInstance(BaseSigningService serviceInstance, GoogleSigned signingInstance)
 {
     S_SigningInstances[serviceInstance.GetType()] = signingInstance;
 }