Esempio n. 1
0
        public async Task <User> Register(string name, string username, string password)
        {
            Uri registerURI = new Uri(endpoint + "/user");

            HttpClient client = GetDefaultClient(null);

            string json = JsonConvert.SerializeObject(new Entities.NewUser(name, username, password));

            HttpStringContent   stringContent = new HttpStringContent(json, UnicodeEncoding.Utf8, Constants.JSON_HEADER);
            HttpResponseMessage response      = await client.PostAsync(registerURI, stringContent);

            Debug.WriteLine("Register response = " + response.StatusCode);

            if (response.StatusCode != Windows.Web.Http.HttpStatusCode.Created || !response.IsSuccessStatusCode)
            {
                return(null);
            }

            string content = await response.Content.ReadAsStringAsync();

            GenericResponse registerReponse = JsonConvert.DeserializeObject <GenericResponse>(content);

            if (registerReponse == null || registerReponse.Code != 3)
            {
                return(null);
            }
            Debug.WriteLine("Register response = " + registerReponse.ToString());
            return(await Login(username, password));
        }
Esempio n. 2
0
        public void Send_Synchronous_OK()
        {
            var message = CreateMessage();

            // post a reply on the syncreply queue before posting the actual message
            var mockMessage = CreateMockMessage(message);

            mockMessage.To      = MockFactory.Helsenorge.SynchronousReply.Name;
            mockMessage.ReplyTo = MockFactory.OtherParty.Synchronous.Name;
            mockMessage.Queue   = MockFactory.Helsenorge.SynchronousReply.Messages;
            MockFactory.Helsenorge.SynchronousReply.Messages.Add(mockMessage);

            var response = RunAndHandleException(Client.SendAndWaitAsync(Logger, message));

            var logProcessedMessage = MockLoggerProvider.Entries.Where(l => l.LogLevel == LogLevel.Information &&
                                                                       l.Message.Contains($"Removing processed message { mockMessage.MessageId} from Herid { MockFactory.OtherHerId } from queue { MockFactory.Helsenorge.SynchronousReply.Name}. Correlation = { message.MessageId }"));

            Assert.AreEqual(1, logProcessedMessage.Count());

            var logEntry = MockLoggerProvider.Entries.Where(l => l.LogLevel == LogLevel.Information &&
                                                            l.Message.Contains("ResponseTime") &&
                                                            l.Message.EndsWith(" ms"));

            Assert.AreEqual(1, logEntry.Count());
            // make sure the content is what we expect
            Assert.AreEqual(GenericResponse.ToString(), response.ToString());
            // message should be gone from our sync reply
            Assert.AreEqual(0, MockFactory.Helsenorge.SynchronousReply.Messages.Count);
        }
        public void Send_Synchronous_OK()
        {
            var message = CreateMessage();

            // post a reply on the syncreply queue before posting the actual message
            var mockMessage = CreateMockMessage(message);

            mockMessage.To      = MockFactory.Helsenorge.SynchronousReply.Name;
            mockMessage.ReplyTo = MockFactory.OtherParty.Synchronous.Name;
            mockMessage.Queue   = MockFactory.Helsenorge.SynchronousReply.Messages;
            MockFactory.Helsenorge.SynchronousReply.Messages.Add(mockMessage);

            var response = RunAndHandleException(Client.SendAndWaitAsync(Logger, message));

            // make sure the content is what we expect
            Assert.AreEqual(GenericResponse.ToString(), response.ToString());
            // message should be gone from our sync reply
            Assert.AreEqual(0, MockFactory.Helsenorge.SynchronousReply.Messages.Count);
        }
Esempio n. 4
0
        //Using the endpointID (Required), this will return all information about the endpoint.
        //This can include the name, IP, malware status, etc.
        public static GetManagedEndpointDetailsResult GetManagedEndpointDetails(Item item)
        {
            JToken parameters = new JObject
            {
                ["endpointId"] = item.Id
            };
            Client          test         = ApiPass();
            Request         requester    = test.NewRequest("getManagedEndpointDetails", parameters);
            GenericResponse testResponse = test.Rpc(requester);
            var             model        = JsonConvert.DeserializeObject <BitDefenderApiResponse <GetManagedEndpointDetailsResult> >(testResponse.ToString());

            return(model.Result);
        }
Esempio n. 5
0
        //Using the parentID paramter, this returns a list of endpoints that are under a specific folder.
        //parentID would be the target group.
        public static GetEndpointListResult GetEndpoints(String parentID)
        {
            JToken parameters = new JObject
            {
                ["parentId"] = parentID
            };
            Client          test         = ApiPass();
            Request         requester    = test.NewRequest("getEndpointsList", parameters);
            GenericResponse testResponse = test.Rpc(requester);
            var             model        = JsonConvert.DeserializeObject <BitDefenderApiResponse <GetEndpointListResult> >(testResponse.ToString());

            return(model.Result);
        }
Esempio n. 6
0
        //This retrieves a list of groups under a specified group using the paramter ParentID
        //Returns ID of group and the Name of the group.
        public static List <GetCustomGroupsResult> GetCustomGroupList(string parentID)
        {
            JToken parameters = new JObject();

            if (!String.IsNullOrWhiteSpace(parentID))
            {
                parameters["parentId"] = parentID;
            }
            Client          test         = ApiPass();
            Request         request      = test.NewRequest("getCustomGroupsList", parameters);
            GenericResponse testResponse = test.Rpc(request);
            var             model        = JsonConvert.DeserializeObject <BitDefenderApiResponse <List <GetCustomGroupsResult> > >(testResponse.ToString());

            return(model.Result);
        }