nebius/SWE-bench-extra huggingface dataset:
Repository: oasis-open/cti-python-stix2

Issue:
is labels optional
Hi,
As an exercise I'm starting a similar Scala library for STIX 2.1, at:

   [scalastix]( https://github.com/workingDog/scalastix)

According to the specs and as part of the common properties, labels is optional.
However, there are SDOs (e.g. Indicator) where it is required. Is this correct?
labels are optional but not when required!

I see that labels are not part of the python COMMON_PROPERTIES.
Should I do the same?

Comments:

Patch:
diff --git a/stix2/common.py b/stix2/common.py
index 29cbf62..c8c243d 100644
--- a/stix2/common.py
+++ b/stix2/common.py
@@ -2,7 +2,7 @@
 
 from .other import ExternalReference, GranularMarking
 from .properties import (BooleanProperty, ListProperty, ReferenceProperty,
-                         TimestampProperty)
+                         StringProperty, TimestampProperty)
 from .utils import NOW
 
 COMMON_PROPERTIES = {
@@ -11,6 +11,7 @@ COMMON_PROPERTIES = {
     'modified': TimestampProperty(default=lambda: NOW),
     'external_references': ListProperty(ExternalReference),
     'revoked': BooleanProperty(),
+    'labels': ListProperty(StringProperty),
     'created_by_ref': ReferenceProperty(type="identity"),
     'object_marking_refs': ListProperty(ReferenceProperty(type="marking-definition")),
     'granular_markings': ListProperty(GranularMarking),
diff --git a/stix2/sdo.py b/stix2/sdo.py
index 693b750..a2f0062 100644
--- a/stix2/sdo.py
+++ b/stix2/sdo.py
@@ -57,7 +57,6 @@ class Identity(_STIXBase):
     _properties.update({
         'type': TypeProperty(_type),
         'id': IDProperty(_type),
-        'labels': ListProperty(StringProperty),
         'name': StringProperty(required=True),
         'description': StringProperty(),
         'identity_class': StringProperty(required=True),


Test patch:
diff --git a/stix2/test/test_attack_pattern.py b/stix2/test/test_attack_pattern.py
index c0891a5..618875e 100644
--- a/stix2/test/test_attack_pattern.py
+++ b/stix2/test/test_attack_pattern.py
@@ -67,4 +67,15 @@ def test_parse_attack_pattern(data):
     assert ap.external_references[0].source_name == 'capec'
     assert ap.name == "Spear Phishing"
 
+
+def test_attack_pattern_invalid_labels():
+    with pytest.raises(stix2.exceptions.InvalidValueError):
+        stix2.AttackPattern(
+            id="attack-pattern--0c7b5b88-8ff7-4a4d-aa9d-feb398cd0061",
+            created="2016-05-12T08:17:27Z",
+            modified="2016-05-12T08:17:27Z",
+            name="Spear Phishing",
+            labels=1
+        )
+
 # TODO: Add other examples
Repository: oasis-open/cti-python-stix2

Issue:
make_constant() should check if value is already a constant
``` python
>>> from stix2.patterns import StringConstant
>>> from stix2.patterns import make_constant
>>> a = StringConstant('foo')
>>> make_constant(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lu/Projects/cti-python-stix2/stix2/patterns.py", line 166, in make_constant
    raise ValueError("Unable to create a constant from %s" % value)
ValueError: Unable to create a constant from 'foo'
```

Comments:

Patch:
diff --git a/stix2/patterns.py b/stix2/patterns.py
index 23ce71b..3f9cbd9 100644
--- a/stix2/patterns.py
+++ b/stix2/patterns.py
@@ -147,6 +147,9 @@ class ListConstant(_Constant):
 
 
 def make_constant(value):
+    if isinstance(value, _Constant):
+        return value
+
     try:
         return parse_into_datetime(value)
     except ValueError:


Test patch:
diff --git a/stix2/test/test_pattern_expressions.py b/stix2/test/test_pattern_expressions.py
index 74a7d0f..14e3774 100644
--- a/stix2/test/test_pattern_expressions.py
+++ b/stix2/test/test_pattern_expressions.py
@@ -372,3 +372,9 @@ def test_invalid_startstop_qualifier():
         stix2.StartStopQualifier(datetime.date(2016, 6, 1),
                                  'foo')
     assert 'is not a valid argument for a Start/Stop Qualifier' in str(excinfo)
+
+
+def test_make_constant_already_a_constant():
+    str_const = stix2.StringConstant('Foo')
+    result = stix2.patterns.make_constant(str_const)
+    assert result is str_const
Repository: oasis-open/cti-python-stix2

Issue:
The instance of MarkingDefinition cannot pass validation because the 'created' property does't have millisecond.
Here is the screenshot:
![marking](https://user-images.githubusercontent.com/5939857/47416920-56c50f00-d7a9-11e8-87a7-aa9b1f82cdb7.PNG)

Source code:
![marking_class](https://user-images.githubusercontent.com/5939857/47417251-2af65900-d7aa-11e8-8914-5b1f0312bbb3.PNG)

Does the 'created' property should be
![property](https://user-images.githubusercontent.com/5939857/47417384-73ae1200-d7aa-11e8-86b3-7960130ca96f.PNG)
to pass validation?


Comments:

Patch:
diff --git a/stix2/v20/common.py b/stix2/v20/common.py
index c66b8f6..d574c92 100644
--- a/stix2/v20/common.py
+++ b/stix2/v20/common.py
@@ -1,6 +1,7 @@
 """STIX 2 Common Data Types and Properties."""
 
 from collections import OrderedDict
+import copy
 
 from ..base import _cls_init, _STIXBase
 from ..markings import _MarkingsMixin
@@ -124,6 +125,13 @@ class MarkingDefinition(_STIXBase, _MarkingsMixin):
             except KeyError:
                 raise ValueError("definition_type must be a valid marking type")
 
+            if marking_type == TLPMarking:
+                # TLP instances in the spec have millisecond precision unlike other markings
+                self._properties = copy.deepcopy(self._properties)
+                self._properties.update([
+                    ('created', TimestampProperty(default=lambda: NOW, precision='millisecond')),
+                ])
+
             if not isinstance(kwargs['definition'], marking_type):
                 defn = _get_dict(kwargs['definition'])
                 kwargs['definition'] = marking_type(**defn)


Test patch:
diff --git a/stix2/test/test_markings.py b/stix2/test/test_markings.py
index ec8b664..49803f3 100644
--- a/stix2/test/test_markings.py
+++ b/stix2/test/test_markings.py
@@ -11,7 +11,7 @@ from .constants import MARKING_DEFINITION_ID
 EXPECTED_TLP_MARKING_DEFINITION = """{
     "type": "marking-definition",
     "id": "marking-definition--613f2e26-407d-48c7-9eca-b8e91df99dc9",
-    "created": "2017-01-20T00:00:00Z",
+    "created": "2017-01-20T00:00:00.000Z",
     "definition_type": "tlp",
     "definition": {
         "tlp": "white"
Repository: oasis-open/cti-python-stix2

Issue:
Placing GranularMarking on id property causes ValueError
https://github.com/oasis-open/cti-python-stix2/blob/6faf6b9fa1bfe65250ac07eaab322ff0f4be6d59/stix2/properties.py#L540

```
Traceback (most recent call last):
  File "C:\Users\user-1\cti-python-stix2\stix2\base.py", line 104, in _check_property
    kwargs[prop_name] = prop.clean(kwargs[prop_name])
  File "C:\Users\user-1\cti-python-stix2\stix2\properties.py", line 216, in clean
    valid = self.contained.clean(item)
  File "C:\Users\user-1\cti-python-stix2\stix2\properties.py", line 547, in clean
    raise ValueError("must adhere to selector syntax.")
ValueError: must adhere to selector syntax.
```

Comments:

Patch:
diff --git a/stix2/properties.py b/stix2/properties.py
index c876c11..a267eb5 100644
--- a/stix2/properties.py
+++ b/stix2/properties.py
@@ -537,7 +537,7 @@ def enumerate_types(types, spec_version):
     return return_types
 
 
-SELECTOR_REGEX = re.compile(r"^[a-z0-9_-]{3,250}(\.(\[\d+\]|[a-z0-9_-]{1,250}))*$")
+SELECTOR_REGEX = re.compile(r"^([a-z0-9_-]{3,250}(\.(\[\d+\]|[a-z0-9_-]{1,250}))*|id)$")
 
 
 class SelectorProperty(Property):


Test patch:
diff --git a/stix2/test/v20/test_granular_markings.py b/stix2/test/v20/test_granular_markings.py
index e912cc1..ae2da3b 100644
--- a/stix2/test/v20/test_granular_markings.py
+++ b/stix2/test/v20/test_granular_markings.py
@@ -1089,3 +1089,17 @@ def test_clear_marking_not_present(data):
     """Test clearing markings for a selector that has no associated markings."""
     with pytest.raises(MarkingNotFoundError):
         data = markings.clear_markings(data, ["labels"])
+
+
+def test_set_marking_on_id_property():
+    malware = Malware(
+        granular_markings=[
+            {
+                "selectors": ["id"],
+                "marking_ref": MARKING_IDS[0],
+            },
+        ],
+        **MALWARE_KWARGS
+    )
+
+    assert "id" in malware["granular_markings"][0]["selectors"]
diff --git a/stix2/test/v21/test_granular_markings.py b/stix2/test/v21/test_granular_markings.py
index 1c3194b..ff8fe26 100644
--- a/stix2/test/v21/test_granular_markings.py
+++ b/stix2/test/v21/test_granular_markings.py
@@ -1307,3 +1307,17 @@ def test_clear_marking_not_present(data):
     """Test clearing markings for a selector that has no associated markings."""
     with pytest.raises(MarkingNotFoundError):
         markings.clear_markings(data, ["malware_types"])
+
+
+def test_set_marking_on_id_property():
+    malware = Malware(
+        granular_markings=[
+            {
+                "selectors": ["id"],
+                "marking_ref": MARKING_IDS[0],
+            },
+        ],
+        **MALWARE_KWARGS
+    )
+
+    assert "id" in malware["granular_markings"][0]["selectors"]
Repository: oasis-open/cti-python-stix2

Issue:
Pattern AST creation bug
Comparison expression ORs can get changed to ANDs:

```python
from stix2.pattern_visitor import create_pattern_object

ast = create_pattern_object(pattern="[a:b=1 AND a:b=2 OR a:b=3]")

print(ast)
```
produces
```
[a:b = 1 AND a:b = 2 AND a:b = 3]
```


Comments:

Patch:
diff --git a/stix2/pattern_visitor.py b/stix2/pattern_visitor.py
index 5b8300f..c4deb64 100644
--- a/stix2/pattern_visitor.py
+++ b/stix2/pattern_visitor.py
@@ -49,6 +49,9 @@ def check_for_valid_timetamp_syntax(timestamp_string):
     return _TIMESTAMP_RE.match(timestamp_string)
 
 
+def same_boolean_operator(current_op, op_token):
+    return current_op == op_token.symbol.text
+
 
 class STIXPatternVisitorForSTIX2():
     classes = {}
@@ -131,7 +134,7 @@ class STIXPatternVisitorForSTIX2():
         if len(children) == 1:
             return children[0]
         else:
-            if isinstance(children[0], _BooleanExpression):
+            if isinstance(children[0], _BooleanExpression) and same_boolean_operator(children[0].operator, children[1]):
                 children[0].operands.append(children[2])
                 return children[0]
             else:


Test patch:
diff --git a/stix2/test/v20/test_pattern_expressions.py b/stix2/test/v20/test_pattern_expressions.py
index a96d3b8..0e0a9ca 100644
--- a/stix2/test/v20/test_pattern_expressions.py
+++ b/stix2/test/v20/test_pattern_expressions.py
@@ -511,6 +511,16 @@ def test_parsing_start_stop_qualified_expression():
     ) == "[ipv4-addr:value = '1.2.3.4'] START '2016-06-01T00:00:00Z' STOP '2017-03-12T08:30:00Z'"
 
 
+def test_parsing_mixed_boolean_expression_1():
+    patt_obj = create_pattern_object("[a:b = 1 AND a:b = 2 OR a:b = 3]",)
+    assert str(patt_obj) == "[a:b = 1 AND a:b = 2 OR a:b = 3]"
+
+
+def test_parsing_mixed_boolean_expression_2():
+    patt_obj = create_pattern_object("[a:b = 1 OR a:b = 2 AND a:b = 3]",)
+    assert str(patt_obj) == "[a:b = 1 OR a:b = 2 AND a:b = 3]"
+
+
 def test_parsing_illegal_start_stop_qualified_expression():
     with pytest.raises(ValueError):
         create_pattern_object("[ipv4-addr:value = '1.2.3.4'] START '2016-06-01' STOP '2017-03-12T08:30:00Z'", version="2.0")
diff --git a/stix2/test/v21/test_pattern_expressions.py b/stix2/test/v21/test_pattern_expressions.py
index 8294a41..b574e05 100644
--- a/stix2/test/v21/test_pattern_expressions.py
+++ b/stix2/test/v21/test_pattern_expressions.py
@@ -644,6 +644,16 @@ def test_parsing_boolean():
     assert str(patt_obj) == "[network-traffic:is_active = true]"
 
 
+def test_parsing_mixed_boolean_expression_1():
+    patt_obj = create_pattern_object("[a:b = 1 AND a:b = 2 OR a:b = 3]",)
+    assert str(patt_obj) == "[a:b = 1 AND a:b = 2 OR a:b = 3]"
+
+
+def test_parsing_mixed_boolean_expression_2():
+    patt_obj = create_pattern_object("[a:b = 1 OR a:b = 2 AND a:b = 3]",)
+    assert str(patt_obj) == "[a:b = 1 OR a:b = 2 AND a:b = 3]"
+
+
 def test_parsing_multiple_slashes_quotes():
     patt_obj = create_pattern_object("[ file:name = 'weird_name\\'' ]", version="2.1")
     assert str(patt_obj) == "[file:name = 'weird_name\\'']"
Repository: oasis-open/cti-python-stix2

Issue:
Sighting: where_sighted_refs enforced with wrong types
STIX 2.1 spec section 5.2 says for the `where_sighted_refs` property of the Sighting relationship:

```
This property MUST reference only Identity or Location SDOs.
```

But the stix2 library only allows Identity.  This should be fixed to also allow Location references.

https://github.com/oasis-open/cti-python-stix2/blob/a751df32c681e3ddfef92f29b91c071b84e91033/stix2/v21/sro.py#L89

Comments:

Patch:
diff --git a/stix2/v21/sro.py b/stix2/v21/sro.py
index d287373..e6eada6 100644
--- a/stix2/v21/sro.py
+++ b/stix2/v21/sro.py
@@ -86,7 +86,7 @@ class Sighting(_RelationshipObject):
         ('count', IntegerProperty(min=0, max=999999999)),
         ('sighting_of_ref', ReferenceProperty(valid_types="SDO", spec_version='2.1', required=True)),
         ('observed_data_refs', ListProperty(ReferenceProperty(valid_types='observed-data', spec_version='2.1'))),
-        ('where_sighted_refs', ListProperty(ReferenceProperty(valid_types='identity', spec_version='2.1'))),
+        ('where_sighted_refs', ListProperty(ReferenceProperty(valid_types=['identity', 'location'], spec_version='2.1'))),
         ('summary', BooleanProperty()),
         ('revoked', BooleanProperty(default=lambda: False)),
         ('labels', ListProperty(StringProperty)),


Test patch:
diff --git a/stix2/test/v21/test_sighting.py b/stix2/test/v21/test_sighting.py
index 0493b71..0ef5faa 100644
--- a/stix2/test/v21/test_sighting.py
+++ b/stix2/test/v21/test_sighting.py
@@ -5,7 +5,9 @@ import pytz
 
 import stix2
 
-from .constants import IDENTITY_ID, INDICATOR_ID, SIGHTING_ID, SIGHTING_KWARGS
+from .constants import (
+    IDENTITY_ID, INDICATOR_ID, LOCATION_ID, SIGHTING_ID, SIGHTING_KWARGS,
+)
 
 EXPECTED_SIGHTING = """{
     "type": "sighting",
@@ -15,7 +17,8 @@ EXPECTED_SIGHTING = """{
     "modified": "2016-04-06T20:06:37.000Z",
     "sighting_of_ref": "indicator--a740531e-63ff-4e49-a9e1-a0a3eed0e3e7",
     "where_sighted_refs": [
-        "identity--311b2d2d-f010-4473-83ec-1edf84858f4c"
+        "identity--311b2d2d-f010-4473-83ec-1edf84858f4c",
+        "location--a6e9345f-5a15-4c29-8bb3-7dcc5d168d64"
     ]
 }"""
 
@@ -41,7 +44,7 @@ def test_sighting_all_required_properties():
         created=now,
         modified=now,
         sighting_of_ref=INDICATOR_ID,
-        where_sighted_refs=[IDENTITY_ID],
+        where_sighted_refs=[IDENTITY_ID, LOCATION_ID],
     )
     assert str(s) == EXPECTED_SIGHTING
 
@@ -101,6 +104,7 @@ def test_create_sighting_from_objects_rather_than_ids(malware):  # noqa: F811
             "type": "sighting",
             "where_sighted_refs": [
                 IDENTITY_ID,
+                LOCATION_ID,
             ],
         },
     ],
@@ -114,4 +118,4 @@ def test_parse_sighting(data):
     assert sighting.created == dt.datetime(2016, 4, 6, 20, 6, 37, tzinfo=pytz.utc)
     assert sighting.modified == dt.datetime(2016, 4, 6, 20, 6, 37, tzinfo=pytz.utc)
     assert sighting.sighting_of_ref == INDICATOR_ID
-    assert sighting.where_sighted_refs == [IDENTITY_ID]
+    assert sighting.where_sighted_refs == [IDENTITY_ID, LOCATION_ID]
Repository: oasis-open/cti-stix-validator

Issue:
The pattern validator should not be invoked for non-STIX patterns
If the pattern type is snort, the STIX validator will still try to see if it is valid for the STIX Pattern language - which of course it isn't.  We should not output a warning in these cases.

Comments:

Patch:
diff --git a/stix2validator/v21/musts.py b/stix2validator/v21/musts.py
index 9c71fa9..776adc4 100644
--- a/stix2validator/v21/musts.py
+++ b/stix2validator/v21/musts.py
@@ -408,6 +408,9 @@ def patterns(instance, options):
     if instance['type'] != 'indicator' or 'pattern' not in instance:
         return
 
+    if instance['pattern_type'] != 'stix':
+        return
+
     pattern = instance['pattern']
     if not isinstance(pattern, string_types):
         return  # This error already caught by schemas


Test patch:
diff --git a/stix2validator/test/v21/indicator_tests.py b/stix2validator/test/v21/indicator_tests.py
index 778827c..b45ae39 100644
--- a/stix2validator/test/v21/indicator_tests.py
+++ b/stix2validator/test/v21/indicator_tests.py
@@ -240,3 +240,15 @@ class IndicatorTestCases(ValidatorTest):
         self.assertFalseWithOptions(indicator)
 
         self.check_ignore(indicator, 'indicator-properties')
+
+    def test_indicator_different_pattern_type_does_not_get_validated(self):
+        pattern = ("alert tcp any any <> any 80 (msg:\"SHA256 Alert\";"
+                   " protected_content:\"56D6F32151AD8474F40D7B939C2161EE2BBF10023F4AF1DBB3E13260EBDC6342\";"
+                   " hash:sha256; offset:0; length:4;)")
+        indicator = copy.deepcopy(self.valid_indicator)
+        indicator["pattern"] = pattern
+        indicator["pattern_type"] = "snort"
+        indicator["pattern_version"] = "2.9.15"
+
+        results = validate_parsed_json(indicator, self.options)
+        self.assertEqual(results.is_valid, True)
diff --git a/stix2validator/test/v21/network_traffic_tests.py b/stix2validator/test/v21/network_traffic_tests.py
index 7014d89..e38b45b 100644
--- a/stix2validator/test/v21/network_traffic_tests.py
+++ b/stix2validator/test/v21/network_traffic_tests.py
@@ -98,7 +98,9 @@ class ObservedDataTestCases(ValidatorTest):
                 "address_family": "AF_INET",
                 "socket_type": "SOCK_STREAM",
                 "options": {
-                    "foo": "bar"
+                    "SO_TEST": 1000,
+                    "IP_TEST": 100,
+                    "MCAST_TEST": 10
                 }
             }
         }
Repository: oasis-open/cti-stix-validator

Issue:
handle options --verbose and --silent correctly
Related to #50 

The correct combination of these two should be as follows:

|--verbose  |  --silent | desired behavior |
| --- | --- | --- |
|absent (default is False) | absent (default is False) | all messages except those printed by info |
|absent (default is False) | present (True) | no messages printed
| present (True) | absent (default is False) | all messages, including info are printed
| present (True) |  present (True) | error |

Current behavior is:

|--verbose  |  --silent | current behavior |
| --- | --- | --- |
|absent (default is False) | absent (default is False) | all messages except those printed by info |
|absent (default is False) | present (ignored, so the default - False) | all messages except those printed by info |
| present (True) | absent (default is False) | all messages, including info are printed
| present (True) |  present (ignored, so the default - False) | all messages, including info are printed |

Comments:

Patch:
diff --git a/stix2validator/scripts/stix2_validator.py b/stix2validator/scripts/stix2_validator.py
index 15bd7b0..8dda167 100644
--- a/stix2validator/scripts/stix2_validator.py
+++ b/stix2validator/scripts/stix2_validator.py
@@ -292,9 +292,6 @@ def main():
     options = ValidationOptions(args)
 
     try:
-        # Set the output level (e.g., quiet vs. verbose)
-        output.set_level(options.verbose)
-
         if not options.no_cache:
             init_requests_cache(options.refresh_cache)
 
diff --git a/stix2validator/util.py b/stix2validator/util.py
index 4da0be5..327931f 100644
--- a/stix2validator/util.py
+++ b/stix2validator/util.py
@@ -1,5 +1,7 @@
 from collections import Iterable
 
+from .output import error, set_level, set_silent
+
 
 class ValidationOptions(object):
     """Collection of validation options which can be set via command line or
@@ -72,6 +74,12 @@ class ValidationOptions(object):
             self.refresh_cache = refresh_cache
             self.clear_cache = clear_cache
 
+        # Set the output level (e.g., quiet vs. verbose)
+        if self.silent and self.verbose:
+            error('Error: Output can either be silent or verbose, but not both.')
+        set_level(self.verbose)
+        set_silent(self.silent)
+
         # Convert string of comma-separated checks to a list,
         # and convert check code numbers to names
         if self.disabled:


Test patch:
diff --git a/stix2validator/test/bundle_tests.py b/stix2validator/test/bundle_tests.py
index 8f417bd..52235ba 100644
--- a/stix2validator/test/bundle_tests.py
+++ b/stix2validator/test/bundle_tests.py
@@ -1,6 +1,8 @@
 import copy
 import json
 
+import pytest
+
 from . import ValidatorTest
 
 VALID_BUNDLE = u"""
@@ -51,3 +53,8 @@ class BundleTestCases(ValidatorTest):
 
         bundle['objects'][1]['modified'] = "2017-06-22T14:09:00.123Z"
         self.assertTrueWithOptions(bundle)
+
+    def test_silent_and_verbose(self):
+        bundle = json.loads(VALID_BUNDLE)
+        with pytest.raises(SystemExit):
+            self.assertFalseWithOptions(bundle, silent=True, verbose=True)
Repository: oasis-open/cti-taxii-client

Issue:
Accept more flexible content type strings
When checking the content type of packets the client receives, it checks if it is an exact match (https://github.com/oasis-open/cti-taxii-client/blob/master/taxii2client/__init__.py#L481). This fails if for example "; charset=utf-8" is appended to the content type.

Comments:

Patch:
diff --git a/taxii2client/__init__.py b/taxii2client/__init__.py
index bee06a1..0efc770 100644
--- a/taxii2client/__init__.py
+++ b/taxii2client/__init__.py
@@ -478,7 +478,7 @@ class _HTTPConnection(object):
         resp.raise_for_status()
 
         content_type = resp.headers['Content-Type']
-        if content_type != accept:
+        if not content_type.startswith(accept):
             msg = "Unexpected Response Content-Type: {}"
             raise TAXIIServiceException(msg.format(content_type))
 


Test patch:
diff --git a/taxii2client/test/test_client.py b/taxii2client/test/test_client.py
index 597ebb3..3a02747 100644
--- a/taxii2client/test/test_client.py
+++ b/taxii2client/test/test_client.py
@@ -3,7 +3,7 @@ import responses
 
 from taxii2client import (
     MEDIA_TYPE_STIX_V20, MEDIA_TYPE_TAXII_V20, AccessError, ApiRoot,
-    Collection, Server
+    Collection, Server, TAXIIServiceException
 )
 
 TAXII_SERVER = 'example.com'
@@ -394,3 +394,23 @@ def test_get_status(api_root):
     assert len(status.failures) == 1
     assert status.pending_count == 2
     assert len(status.pendings) == 2
+
+
+@responses.activate
+def test_content_type_valid(collection):
+    responses.add(responses.GET, GET_OBJECT_URL, GET_OBJECT_RESPONSE,
+                  status=200, content_type="%s; charset=utf-8" % MEDIA_TYPE_STIX_V20)
+
+    response = collection.get_object('indicator--252c7c11-daf2-42bd-843b-be65edca9f61')
+    indicator = response['objects'][0]
+    assert indicator['id'] == 'indicator--252c7c11-daf2-42bd-843b-be65edca9f61'
+
+
+@responses.activate
+def test_content_type_invalid(collection):
+    responses.add(responses.GET, GET_OBJECT_URL, GET_OBJECT_RESPONSE,
+                  status=200, content_type="taxii")
+
+    with pytest.raises(TAXIIServiceException) as excinfo:
+        collection.get_object('indicator--252c7c11-daf2-42bd-843b-be65edca9f61')
+    assert "Unexpected Response Content-Type" in str(excinfo.value)