Skip to content

Commit 103b6c3

Browse files
committed
fix: fix group creation
1 parent 46171b2 commit 103b6c3

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

Fossology.Rest.Dotnet.Test/FossologyClientTest.cs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Fossology.Rest.Dotnet.Test
1616
{
1717
using System;
1818
using System.Collections.Generic;
19+
using System.ComponentModel.DataAnnotations;
1920
using System.Diagnostics;
2021
using System.IO;
2122
using System.Net;
@@ -736,6 +737,20 @@ public void TestGetGroupList()
736737
Assert.IsTrue(actual.Count > 0);
737738
}
738739

740+
/// <summary>
741+
/// Unit test.
742+
/// </summary>
743+
[TestMethod]
744+
public void TestCreateGroup()
745+
{
746+
const string GroupName = "TestGroup1";
747+
748+
var client = new FossologyClient(LocalUrl, Token);
749+
var actual = client.CreateGroup(GroupName);
750+
Assert.IsNotNull(actual);
751+
Assert.AreEqual(200, actual.Code);
752+
}
753+
739754
/// <summary>
740755
/// Unit test.
741756
/// </summary>
@@ -814,21 +829,38 @@ public void TestCreateLicense()
814829
Assert.AreEqual(201, actual.Code);
815830
}
816831

817-
#if false // not yet supported by Fossology
818832
/// <summary>
819833
/// Unit test.
820834
/// </summary>
821835
[TestMethod]
822-
public void TestCreateGroup()
836+
public void TestFileSearch()
823837
{
824-
const string GroupName = "TestGroup";
825-
826838
var client = new FossologyClient(LocalUrl, Token);
827-
var actual = client.CreateGroup(GroupName);
839+
var hash = new Hash();
840+
hash.Sha1 = "81fe8bfe87576c3ecb22426f8e57847382917acf";
841+
hash.Md5 = "e2fc714c4727ee9395f324cd2e7f331f";
842+
hash.Sha256 = "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589";
843+
hash.Size = 0;
844+
var hashes = new List<Hash>();
845+
hashes.Add(hash);
846+
847+
var actual = client.SearchForFile(hashes);
828848
Assert.IsNotNull(actual);
829-
//Assert.AreEqual("OK", actual.Status);
849+
Assert.IsTrue(actual.Length > 0);
850+
851+
// always returns
852+
// [
853+
// {
854+
// "hash" : {
855+
// "sha1":null,
856+
// "md5":null,
857+
// "sha256":null,
858+
// "size":null
859+
// },
860+
// "message": "Invalid keys"
861+
// }
862+
// ]"
830863
}
831-
#endif
832864

833865
//// ---------------------------------------------------------------------
834866

Fossology.Rest.Dotnet/FossologyClientGroup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public IReadOnlyList<Group> GetGroupList()
5151
return list;
5252
} // GetGroupList()
5353

54-
#if false // not yet supported by Fossology
54+
#if true // not yet supported by Fossology
5555
/// <summary>
5656
/// Creates a new group.
5757
/// </summary>
@@ -65,7 +65,7 @@ public Result CreateGroup(string groupName)
6565
{
6666
var request = new RestRequest(this.Url + "/groups", Method.POST);
6767
request.RequestFormat = DataFormat.Json;
68-
request.AddHeader("groupName", groupName);
68+
request.AddHeader("name", groupName);
6969

7070
var resultRaw = this.api.Execute(request);
7171
var result = JsonConvert.DeserializeObject<Result>(resultRaw.Content);

0 commit comments

Comments
 (0)