Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-19 Thread Martin Kosek
On 06/19/2013 03:12 PM, Alexander Bokovoy wrote:
> On Wed, 19 Jun 2013, Tomas Babej wrote:
>> On Wed 19 Jun 2013 02:36:16 PM CEST, Alexander Bokovoy wrote:
>>> On Wed, 19 Jun 2013, Tomas Babej wrote:
 On 06/11/2013 01:15 PM, Tomas Babej wrote:
> On 06/11/2013 12:59 PM, Alexander Bokovoy wrote:
>> On Tue, 11 Jun 2013, Tomas Babej wrote:
>>> On 06/10/2013 01:13 PM, Tomas Babej wrote:
 Hi,

 Hardcoded values for range parameters such as base RID or range
 size could be the reason the tests produced incorrect results,
 as the ranges could get in conflict with already existing ranges
 on the server.

 Patch dynamically chooses ID and RID range space at the end of
 all ranges already present on the server.

 https://fedorahosted.org/freeipa/ticket/3662

 Tomas
>>>
>>> Patch altered to incorporate minor fixes for recent idrange
>>> objectclass changes.
>>>
>>> Tomas
>>
>>> From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00
>>> 2001
>>> From: Tomas Babej 
>>> Date: Mon, 10 Jun 2013 13:08:50 +0200
>>> Subject: [PATCH] Remove hardcoded values from idrange plugin tests
>>>
>>> Hardcoded values for range parameters such as base RID or range
>>> size could be the reason the tests produced incorrect results,
>>> as the ranges could get in conflict with already existing ranges
>>> on the server.
>>>
>>> Patch dynamically chooses ID and RID range space at the end of
>>> all ranges already present on the server.
>>>
>>> https://fedorahosted.org/freeipa/ticket/3662
>>> ---
>>> ipalib/plugins/idrange.py  |  2 +-
>>> tests/test_xmlrpc/test_range_plugin.py | 90
>>> ++
>>> 2 files changed, 60 insertions(+), 32 deletions(-)
>>>
>>> diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
>>> index
>>> abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363
>>>
>>> 100644
>>> --- a/ipalib/plugins/idrange.py
>>> +++ b/ipalib/plugins/idrange.py
>>> @@ -224,7 +224,7 @@ class idrange(LDAPObject):
>>>if not any((options.get('pkey_only', False),
>>>options.get('raw', False))):
>>>range_type = entry_attrs['iparangetype'][0]
>>> -entry_attrs['iparangetype'] =
>>> self.range_types.get(range_type, None)
>>> +entry_attrs['iparangetype'] =
>>> [self.range_types.get(range_type, None)]
>>>
>>># Remove the objectclass
>>>if not keep_objectclass:
>> Could you please extract this change into an independent patch? I'm
>> thinking purely from possible backporting perspective.
>>
>> Otherwise looks good.
>
> Sure. Patches 0070 and 0071 attached.
>
> I'll link 0071 to the ticket for extending ID range types once it's
> pushed, for record's sake.
>
> Tomas
>
 Patches needed rebase.
>>> The tests now pass on a machine with existing trusts.
>>>
>>> However, I'm getting following errors in dirsrv's error log:
>>>
>>> [19/Jun/2013:15:34:58 +0300] find_sid_for_ldap_entry - [file
>>> ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902850]
>>> into an unused SID.
>>> [19/Jun/2013:15:34:58 +0300] ipa_sidgen_add_post_op - [file
>>> ipa_sidgen.c, line 149]: Cannot add SID to new entry.
>>> [19/Jun/2013:15:34:59 +0300] find_sid_for_ldap_entry - [file
>>> ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902950]
>>> into an unused SID.
>>> [19/Jun/2013:15:34:59 +0300] ipa_sidgen_add_post_op - [file
>>> ipa_sidgen.c, line 149]: Cannot add SID to new entry.
>>> [19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
>>> ipa_range_check.c, line 417]: New primary rid range overlaps with
>>> existing primary rid range.
>>> [19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
>>> ipa_range_check.c, line 417]: New secondary rid range overlaps with
>>> existing secondary rid range.
>>> [19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
>>> ipa_range_check.c, line 417]: New primary rid range overlaps with
>>> existing secondary rid range.
>>> [19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
>>> ipa_range_check.c, line 417]: New base range overlaps with existing base
>>> range.
>>>
>>> I think we still need to improve RID part of calculating the test range..
>>>
>>
>> Aren't those logs that were produced by negative tests?
>>
>> Overlaps are handled by DS plugin, and only then the errors are propagated
>> back to the IPA framework.
> Uhm. Right.
> 
> ACK then.
> 

Pushed both to master.

Martin

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-19 Thread Alexander Bokovoy

On Wed, 19 Jun 2013, Tomas Babej wrote:

On Wed 19 Jun 2013 02:36:16 PM CEST, Alexander Bokovoy wrote:

On Wed, 19 Jun 2013, Tomas Babej wrote:

On 06/11/2013 01:15 PM, Tomas Babej wrote:

On 06/11/2013 12:59 PM, Alexander Bokovoy wrote:

On Tue, 11 Jun 2013, Tomas Babej wrote:

On 06/10/2013 01:13 PM, Tomas Babej wrote:

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas


Patch altered to incorporate minor fixes for recent idrange
objectclass changes.

Tomas



From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00
2001
From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
ipalib/plugins/idrange.py  |  2 +-
tests/test_xmlrpc/test_range_plugin.py | 90
++
2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index
abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363
100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
   if not any((options.get('pkey_only', False),
   options.get('raw', False))):
   range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] =
self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] =
[self.range_types.get(range_type, None)]

   # Remove the objectclass
   if not keep_objectclass:

Could you please extract this change into an independent patch? I'm
thinking purely from possible backporting perspective.

Otherwise looks good.


Sure. Patches 0070 and 0071 attached.

I'll link 0071 to the ticket for extending ID range types once it's
pushed, for record's sake.

Tomas


Patches needed rebase.

The tests now pass on a machine with existing trusts.

However, I'm getting following errors in dirsrv's error log:

[19/Jun/2013:15:34:58 +0300] find_sid_for_ldap_entry - [file
ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902850]
into an unused SID.
[19/Jun/2013:15:34:58 +0300] ipa_sidgen_add_post_op - [file
ipa_sidgen.c, line 149]: Cannot add SID to new entry.
[19/Jun/2013:15:34:59 +0300] find_sid_for_ldap_entry - [file
ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902950]
into an unused SID.
[19/Jun/2013:15:34:59 +0300] ipa_sidgen_add_post_op - [file
ipa_sidgen.c, line 149]: Cannot add SID to new entry.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
ipa_range_check.c, line 417]: New primary rid range overlaps with
existing primary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
ipa_range_check.c, line 417]: New secondary rid range overlaps with
existing secondary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
ipa_range_check.c, line 417]: New primary rid range overlaps with
existing secondary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file
ipa_range_check.c, line 417]: New base range overlaps with existing base
range.

I think we still need to improve RID part of calculating the test range..



Aren't those logs that were produced by negative tests?

Overlaps are handled by DS plugin, and only then the errors are 
propagated back to the IPA framework.

Uhm. Right.

ACK then.


--
/ Alexander Bokovoy

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-19 Thread Tomas Babej

On 06/19/2013 02:36 PM, Alexander Bokovoy wrote:

On Wed, 19 Jun 2013, Tomas Babej wrote:

On 06/11/2013 01:15 PM, Tomas Babej wrote:

On 06/11/2013 12:59 PM, Alexander Bokovoy wrote:

On Tue, 11 Jun 2013, Tomas Babej wrote:

On 06/10/2013 01:13 PM, Tomas Babej wrote:

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas


Patch altered to incorporate minor fixes for recent idrange 
objectclass changes.


Tomas


From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00 
2001

From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
ipalib/plugins/idrange.py  |  2 +-
tests/test_xmlrpc/test_range_plugin.py | 90 
++

2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 
abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363 
100644

--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
if not any((options.get('pkey_only', False),
options.get('raw', False))):
range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = 
self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] = 
[self.range_types.get(range_type, None)]


# Remove the objectclass
if not keep_objectclass:

Could you please extract this change into an independent patch? I'm
thinking purely from possible backporting perspective.

Otherwise looks good.


Sure. Patches 0070 and 0071 attached.

I'll link 0071 to the ticket for extending ID range types once it's 
pushed, for record's sake.


Tomas


Patches needed rebase.

The tests now pass on a machine with existing trusts.

However, I'm getting following errors in dirsrv's error log:

[19/Jun/2013:15:34:58 +0300] find_sid_for_ldap_entry - [file 
ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902850]

into an unused SID.
[19/Jun/2013:15:34:58 +0300] ipa_sidgen_add_post_op - [file 
ipa_sidgen.c, line 149]: Cannot add SID to new entry.
[19/Jun/2013:15:34:59 +0300] find_sid_for_ldap_entry - [file 
ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902950]

into an unused SID.
[19/Jun/2013:15:34:59 +0300] ipa_sidgen_add_post_op - [file 
ipa_sidgen.c, line 149]: Cannot add SID to new entry.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file 
ipa_range_check.c, line 417]: New primary rid range overlaps with

existing primary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file 
ipa_range_check.c, line 417]: New secondary rid range overlaps with

existing secondary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file 
ipa_range_check.c, line 417]: New primary rid range overlaps with

existing secondary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file 
ipa_range_check.c, line 417]: New base range overlaps with existing base

range.

I think we still need to improve RID part of calculating the test range..



Aren't those logs that were produced by negative tests?

Overlaps are handled by DS plugin, and only then the errors are 
propagated back to the IPA framework.


Tomas

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-19 Thread Alexander Bokovoy

On Wed, 19 Jun 2013, Tomas Babej wrote:

On 06/11/2013 01:15 PM, Tomas Babej wrote:

On 06/11/2013 12:59 PM, Alexander Bokovoy wrote:

On Tue, 11 Jun 2013, Tomas Babej wrote:

On 06/10/2013 01:13 PM, Tomas Babej wrote:

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas


Patch altered to incorporate minor fixes for recent idrange 
objectclass changes.


Tomas



From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
ipalib/plugins/idrange.py  |  2 +-
tests/test_xmlrpc/test_range_plugin.py | 90 
++

2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363 
100644

--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
if not any((options.get('pkey_only', False),
options.get('raw', False))):
range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = 
self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] = 
[self.range_types.get(range_type, None)]


# Remove the objectclass
if not keep_objectclass:

Could you please extract this change into an independent patch? I'm
thinking purely from possible backporting perspective.

Otherwise looks good.


Sure. Patches 0070 and 0071 attached.

I'll link 0071 to the ticket for extending ID range types once 
it's pushed, for record's sake.


Tomas


Patches needed rebase.

The tests now pass on a machine with existing trusts.

However, I'm getting following errors in dirsrv's error log:

[19/Jun/2013:15:34:58 +0300] find_sid_for_ldap_entry - [file 
ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902850]
into an unused SID.
[19/Jun/2013:15:34:58 +0300] ipa_sidgen_add_post_op - [file ipa_sidgen.c, line 
149]: Cannot add SID to new entry.
[19/Jun/2013:15:34:59 +0300] find_sid_for_ldap_entry - [file 
ipa_sidgen_common.c, line 522]: Cannot convert Posix ID [1447902950]
into an unused SID.
[19/Jun/2013:15:34:59 +0300] ipa_sidgen_add_post_op - [file ipa_sidgen.c, line 
149]: Cannot add SID to new entry.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file ipa_range_check.c, 
line 417]: New primary rid range overlaps with
existing primary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file ipa_range_check.c, 
line 417]: New secondary rid range overlaps with
existing secondary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file ipa_range_check.c, 
line 417]: New primary rid range overlaps with
existing secondary rid range.
[19/Jun/2013:15:35:01 +0300] ipa_range_check_pre_op - [file ipa_range_check.c, 
line 417]: New base range overlaps with existing base
range.

I think we still need to improve RID part of calculating the test range..

--
/ Alexander Bokovoy

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-19 Thread Tomas Babej

On 06/11/2013 01:15 PM, Tomas Babej wrote:

On 06/11/2013 12:59 PM, Alexander Bokovoy wrote:

On Tue, 11 Jun 2013, Tomas Babej wrote:

On 06/10/2013 01:13 PM, Tomas Babej wrote:

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas


Patch altered to incorporate minor fixes for recent idrange 
objectclass changes.


Tomas



From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
ipalib/plugins/idrange.py  |  2 +-
tests/test_xmlrpc/test_range_plugin.py | 90 
++

2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 
abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363 
100644

--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
if not any((options.get('pkey_only', False),
options.get('raw', False))):
range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = 
self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] = 
[self.range_types.get(range_type, None)]


# Remove the objectclass
if not keep_objectclass:

Could you please extract this change into an independent patch? I'm
thinking purely from possible backporting perspective.

Otherwise looks good.


Sure. Patches 0070 and 0071 attached.

I'll link 0071 to the ticket for extending ID range types once it's 
pushed, for record's sake.


Tomas


Patches needed rebase.

Tomas
From e9fa638312a3c79c7c6fe6a44796509d76be3360 Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Tue, 11 Jun 2013 13:07:06 +0200
Subject: [PATCH 71/71] Return ipaRangeType as a list in idrange commands

To be consistent with the rest of the LDAP commands, return
ipaRangeType as a list of unicode strings.

Regression caused by https://fedorahosted.org/freeipa/ticket/3647
---
 ipalib/plugins/idrange.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
 if not any((options.get('pkey_only', False),
 options.get('raw', False))):
 range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] = [self.range_types.get(range_type, None)]
 
 # Remove the objectclass
 if not keep_objectclass:
-- 
1.8.1.4

From b312c64d703fa4012ad28df96823f5ba3c506d32 Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Tue, 11 Jun 2013 13:05:18 +0200
Subject: [PATCH 70/71] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
 ipatests/test_xmlrpc/test_range_plugin.py | 90 ---
 1 file changed, 59 insertions(+), 31 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_range_plugin.py b/ipatests/test_xmlrpc/test_range_plugin.py
index cbb700e99203fb0ed448f62e6cb7fbeb265ec56b..3292d6a946c8f7c14a3bd276cd6af54a6ccc20a4 100644
--- a/ipatests/test_xmlrpc/test_range_plugin.py
+++ b/ipatests/test_xmlrpc/test_range_plugin.py
@@ -29,62 +29,86 @@ from ipapython.dn import *
 
 import ldap, ldap.sasl, ldap.modlist
 
+id_shift = 0
+rid_shift = 0
+
+for idrange in api.Command['idrange_find']()['result']:
+size = int(idrange['ipaidrangesize'][0])
+base_id = int(idrange['ipabaseid'][0])
+
+id_end = base_id + size
+rid_end = 0
+
+if 'ipabaserid' in idrange:
+base_rid = int(idrange['ipabaserid'][0])
+rid_end = base_rid + size
+
+if 'ipasecondarybaserid' in idrange:
+s

Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-11 Thread Tomas Babej

On 06/11/2013 12:59 PM, Alexander Bokovoy wrote:

On Tue, 11 Jun 2013, Tomas Babej wrote:

On 06/10/2013 01:13 PM, Tomas Babej wrote:

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas


Patch altered to incorporate minor fixes for recent idrange 
objectclass changes.


Tomas



From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
ipalib/plugins/idrange.py  |  2 +-
tests/test_xmlrpc/test_range_plugin.py | 90 
++

2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 
abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363 
100644

--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
if not any((options.get('pkey_only', False),
options.get('raw', False))):
range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = 
self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] = 
[self.range_types.get(range_type, None)]


# Remove the objectclass
if not keep_objectclass:

Could you please extract this change into an independent patch? I'm
thinking purely from possible backporting perspective.

Otherwise looks good.


Sure. Patches 0070 and 0071 attached.

I'll link 0071 to the ticket for extending ID range types once it's 
pushed, for record's sake.


Tomas

From a6b0e82c7ce0db83055d8878342db6c02bc5e752 Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Tue, 11 Jun 2013 13:07:06 +0200
Subject: [PATCH 71/71] Return ipaRangeType as a list in idrange commands

To be consistent with the rest of the LDAP commands, return
ipaRangeType as a list of unicode strings.

Regression caused by https://fedorahosted.org/freeipa/ticket/3647
---
 ipalib/plugins/idrange.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
 if not any((options.get('pkey_only', False),
 options.get('raw', False))):
 range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] = [self.range_types.get(range_type, None)]
 
 # Remove the objectclass
 if not keep_objectclass:
-- 
1.8.1.4

From a7302e45655078b32f7f6d1c82aba7fbb2fc3528 Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Tue, 11 Jun 2013 13:05:18 +0200
Subject: [PATCH 70/71] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
 tests/test_xmlrpc/test_range_plugin.py | 90 ++
 1 file changed, 59 insertions(+), 31 deletions(-)

diff --git a/tests/test_xmlrpc/test_range_plugin.py b/tests/test_xmlrpc/test_range_plugin.py
index ce70433112b3216304356b520026d79be66543cf..f0f881ab914b8c8ff84737be607cd709cceee377 100644
--- a/tests/test_xmlrpc/test_range_plugin.py
+++ b/tests/test_xmlrpc/test_range_plugin.py
@@ -29,62 +29,86 @@ from ipapython.dn import *
 
 import ldap, ldap.sasl, ldap.modlist
 
+id_shift = 0
+rid_shift = 0
+
+for idrange in api.Command['idrange_find']()['result']:
+size = int(idrange['ipaidrangesize'][0])
+base_id = int(idrange['ipabaseid'][0])
+
+id_end = base_id + size
+rid_end = 0
+
+if 'ipabaserid' in idrange:
+base_rid = int(idrange['ipabaserid'][0])
+rid_end = base_rid + size
+
+if 'ipasecondarybaserid' in idrange:
+secondary_base_rid = int(idrange['ipasecondarybaserid'][0])
+rid_end = max(base_

Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-11 Thread Alexander Bokovoy

On Tue, 11 Jun 2013, Tomas Babej wrote:

On 06/10/2013 01:13 PM, Tomas Babej wrote:

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas


Patch altered to incorporate minor fixes for recent idrange 
objectclass changes.


Tomas



From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
ipalib/plugins/idrange.py  |  2 +-
tests/test_xmlrpc/test_range_plugin.py | 90 ++
2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 
abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363
 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
if not any((options.get('pkey_only', False),
options.get('raw', False))):
range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = self.range_types.get(range_type, 
None)
+entry_attrs['iparangetype'] = [self.range_types.get(range_type, 
None)]

# Remove the objectclass
if not keep_objectclass:

Could you please extract this change into an independent patch? I'm
thinking purely from possible backporting perspective.

Otherwise looks good.
--
/ Alexander Bokovoy

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-11 Thread Tomas Babej

On 06/10/2013 01:13 PM, Tomas Babej wrote:

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas


Patch altered to incorporate minor fixes for recent idrange objectclass 
changes.


Tomas
From b35b10f1356c9714776f16aadec7ffbe95e2f41e Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
 ipalib/plugins/idrange.py  |  2 +-
 tests/test_xmlrpc/test_range_plugin.py | 90 ++
 2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index abca492978d04c71b78a89df8e5c2d1d51c06398..54b835e244fb60ee212a9c00223d4294ff8f4363 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -224,7 +224,7 @@ class idrange(LDAPObject):
 if not any((options.get('pkey_only', False),
 options.get('raw', False))):
 range_type = entry_attrs['iparangetype'][0]
-entry_attrs['iparangetype'] = self.range_types.get(range_type, None)
+entry_attrs['iparangetype'] = [self.range_types.get(range_type, None)]
 
 # Remove the objectclass
 if not keep_objectclass:
diff --git a/tests/test_xmlrpc/test_range_plugin.py b/tests/test_xmlrpc/test_range_plugin.py
index ce70433112b3216304356b520026d79be66543cf..f0f881ab914b8c8ff84737be607cd709cceee377 100644
--- a/tests/test_xmlrpc/test_range_plugin.py
+++ b/tests/test_xmlrpc/test_range_plugin.py
@@ -29,62 +29,86 @@ from ipapython.dn import *
 
 import ldap, ldap.sasl, ldap.modlist
 
+id_shift = 0
+rid_shift = 0
+
+for idrange in api.Command['idrange_find']()['result']:
+size = int(idrange['ipaidrangesize'][0])
+base_id = int(idrange['ipabaseid'][0])
+
+id_end = base_id + size
+rid_end = 0
+
+if 'ipabaserid' in idrange:
+base_rid = int(idrange['ipabaserid'][0])
+rid_end = base_rid + size
+
+if 'ipasecondarybaserid' in idrange:
+secondary_base_rid = int(idrange['ipasecondarybaserid'][0])
+rid_end = max(base_rid, secondary_base_rid) + size
+
+if id_shift < id_end:
+id_shift = id_end + 100
+
+if rid_shift < rid_end:
+rid_shift = rid_end + 100
+
 testrange1 = u'testrange1'
-testrange1_base_id = 90
+testrange1_base_id = id_shift + 90
 testrange1_size = 9
-testrange1_base_rid = 1
-testrange1_secondary_base_rid = 20
+testrange1_base_rid = rid_shift + 1
+testrange1_secondary_base_rid = rid_shift + 20
 
 testrange2 = u'testrange2'
-testrange2_base_id = 100
+testrange2_base_id = id_shift + 100
 testrange2_size = 50
-testrange2_base_rid = 100
-testrange2_secondary_base_rid = 1000
+testrange2_base_rid = rid_shift + 100
+testrange2_secondary_base_rid = rid_shift + 1000
 
 testrange3 = u'testrange3'
-testrange3_base_id = 200
+testrange3_base_id = id_shift + 200
 testrange3_size = 50
-testrange3_base_rid = 70
-testrange3_secondary_base_rid = 1100
+testrange3_base_rid = rid_shift + 70
+testrange3_secondary_base_rid = rid_shift + 1100
 
 testrange4 = u'testrange4'
-testrange4_base_id = 300
+testrange4_base_id = id_shift + 300
 testrange4_size = 50
-testrange4_base_rid = 200
-testrange4_secondary_base_rid = 1030
+testrange4_base_rid = rid_shift + 200
+testrange4_secondary_base_rid = rid_shift + 1030
 
 testrange5 = u'testrange5'
-testrange5_base_id = 400
+testrange5_base_id = id_shift + 400
 testrange5_size = 50
-testrange5_base_rid = 1020
-testrange5_secondary_base_rid = 1200
+testrange5_base_rid = rid_shift + 1020
+testrange5_secondary_base_rid = rid_shift + 1200
 
 testrange6 = u'testrange6'
-testrange6_base_id = 130
+testrange6_base_id = id_shift + 130
 testrange6_size = 50
-testrange6_base_rid = 500
-testrange6_secondary_base_rid = 1300
+testrange6_base_rid = rid_shift + 500
+testrange6_secondary_base_rid = rid_shift + 1300
 
 testrange7 = u'testrange7'
-testrange7_base_id = 600
+testrange7_base_id = id_shift + 600
 testrange7_size = 50
-testrange7_base_rid = 600
-testrange7_secondary_base_rid = 649
+testrange7_base_rid = rid_shift + 600
+testrange7_secondary_base_rid = rid_shift + 649
 
 testrange8 = u'testrange8'
-testrange8_base_id = 700
+testrange8_base_id = id_shift + 700
 testrange8_size = 50
-testrange8_base_rid = 700
+testrange8_base_

[Freeipa-devel] [PATCH 0070] Remove hardcoded values from idrange plugin tests

2013-06-10 Thread Tomas Babej

Hi,

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662

Tomas
From 4bb6e622fadc9406f28d7089cd2d45408869b28c Mon Sep 17 00:00:00 2001
From: Tomas Babej 
Date: Mon, 10 Jun 2013 13:08:50 +0200
Subject: [PATCH] Remove hardcoded values from idrange plugin tests

Hardcoded values for range parameters such as base RID or range
size could be the reason the tests produced incorrect results,
as the ranges could get in conflict with already existing ranges
on the server.

Patch dynamically chooses ID and RID range space at the end of
all ranges already present on the server.

https://fedorahosted.org/freeipa/ticket/3662
---
 tests/test_xmlrpc/test_range_plugin.py | 88 ++
 1 file changed, 57 insertions(+), 31 deletions(-)

diff --git a/tests/test_xmlrpc/test_range_plugin.py b/tests/test_xmlrpc/test_range_plugin.py
index ce70433112b3216304356b520026d79be66543cf..0443cfd2debeaea144584979239a192713b13057 100644
--- a/tests/test_xmlrpc/test_range_plugin.py
+++ b/tests/test_xmlrpc/test_range_plugin.py
@@ -29,62 +29,86 @@ from ipapython.dn import *
 
 import ldap, ldap.sasl, ldap.modlist
 
+id_shift = 0
+rid_shift = 0
+
+for idrange in api.Command['idrange_find']()['result']:
+size = int(idrange['ipaidrangesize'][0])
+base_id = int(idrange['ipabaseid'][0])
+
+id_end = base_id + size
+rid_end = 0
+
+if 'ipabaserid' in idrange:
+base_rid = int(idrange['ipabaserid'][0])
+rid_end = base_rid + size
+
+if 'ipasecondarybaserid' in idrange:
+secondary_base_rid = int(idrange['ipasecondarybaserid'][0])
+rid_end = max(base_rid, secondary_base_rid) + size
+
+if id_shift < id_end:
+id_shift = id_end + 100
+
+if rid_shift < rid_end:
+rid_shift = rid_end + 100
+
 testrange1 = u'testrange1'
-testrange1_base_id = 90
+testrange1_base_id = id_shift + 90
 testrange1_size = 9
-testrange1_base_rid = 1
-testrange1_secondary_base_rid = 20
+testrange1_base_rid = rid_shift + 1
+testrange1_secondary_base_rid = rid_shift + 20
 
 testrange2 = u'testrange2'
-testrange2_base_id = 100
+testrange2_base_id = id_shift + 100
 testrange2_size = 50
-testrange2_base_rid = 100
-testrange2_secondary_base_rid = 1000
+testrange2_base_rid = rid_shift + 100
+testrange2_secondary_base_rid = rid_shift + 1000
 
 testrange3 = u'testrange3'
-testrange3_base_id = 200
+testrange3_base_id = id_shift + 200
 testrange3_size = 50
-testrange3_base_rid = 70
-testrange3_secondary_base_rid = 1100
+testrange3_base_rid = rid_shift + 70
+testrange3_secondary_base_rid = rid_shift + 1100
 
 testrange4 = u'testrange4'
-testrange4_base_id = 300
+testrange4_base_id = id_shift + 300
 testrange4_size = 50
-testrange4_base_rid = 200
-testrange4_secondary_base_rid = 1030
+testrange4_base_rid = rid_shift + 200
+testrange4_secondary_base_rid = rid_shift + 1030
 
 testrange5 = u'testrange5'
-testrange5_base_id = 400
+testrange5_base_id = id_shift + 400
 testrange5_size = 50
-testrange5_base_rid = 1020
-testrange5_secondary_base_rid = 1200
+testrange5_base_rid = rid_shift + 1020
+testrange5_secondary_base_rid = rid_shift + 1200
 
 testrange6 = u'testrange6'
-testrange6_base_id = 130
+testrange6_base_id = id_shift + 130
 testrange6_size = 50
-testrange6_base_rid = 500
-testrange6_secondary_base_rid = 1300
+testrange6_base_rid = rid_shift + 500
+testrange6_secondary_base_rid = rid_shift + 1300
 
 testrange7 = u'testrange7'
-testrange7_base_id = 600
+testrange7_base_id = id_shift + 600
 testrange7_size = 50
-testrange7_base_rid = 600
-testrange7_secondary_base_rid = 649
+testrange7_base_rid = rid_shift + 600
+testrange7_secondary_base_rid = rid_shift + 649
 
 testrange8 = u'testrange8'
-testrange8_base_id = 700
+testrange8_base_id = id_shift + 700
 testrange8_size = 50
-testrange8_base_rid = 700
+testrange8_base_rid = rid_shift + 700
 
 testrange9 = u'testrange9'
-testrange9_base_id = 800
+testrange9_base_id = id_shift + 800
 testrange9_size = 50
-testrange9_base_rid = 800
+testrange9_base_rid = rid_shift + 800
 
 testrange10 = u'testrange10'
-testrange10_base_id = 900
+testrange10_base_id = id_shift + 900
 testrange10_size = 50
-testrange10_base_rid = 900
+testrange10_base_rid = rid_shift + 900
 
 testrange9_dn = "cn={name},cn=ranges,cn=etc,{basedn}".format(name=testrange9,
   basedn=api.env.basedn)
@@ -123,9 +147,9 @@ testtrust_add = dict(
 )
 
 user1 = u'tuser1'
-user1_uid = 90
+user1_uid = id_shift + 90
 group1 = u'group1'
-group1_gid = 900100
+group1_gid = id_shift + 900100
 
 
 class test_range(Declarative):
@@ -295,7 +319,9 @@ class test_range(Declarative):
 
 dict(