toxbank-investigation 0.0.1pre-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +101 -0
- data/LICENSE +674 -0
- data/README +14 -0
- data/Rakefile +31 -0
- data/application.rb +246 -0
- data/bin/toxbank-investigation-install +76 -0
- data/config/production.rb +9 -0
- data/config.ru +5 -0
- data/java/config/isa_configurator/cellcount_flowcytometry.xml +1 -0
- data/java/config/isa_configurator/cellsorting_flowcyt.xml +5 -0
- data/java/config/isa_configurator/clinical_chemistry.xml +1 -0
- data/java/config/isa_configurator/copynumvariation_micro.xml +1 -0
- data/java/config/isa_configurator/dnamethylation_micro.xml +1 -0
- data/java/config/isa_configurator/dnamethylation_seq.xml +1 -0
- data/java/config/isa_configurator/envgen_survey_seq.xml +1 -0
- data/java/config/isa_configurator/genome_seq.xml +1 -0
- data/java/config/isa_configurator/hematology.xml +1 -0
- data/java/config/isa_configurator/heterozygosity_micro.xml +1 -0
- data/java/config/isa_configurator/histology.xml +1 -0
- data/java/config/isa_configurator/histonemodification_seq.xml +1 -0
- data/java/config/isa_configurator/metaboliteprofiling_ms.xml +114 -0
- data/java/config/isa_configurator/metaboliteprofiling_nmr.xml +114 -0
- data/java/config/isa_configurator/metagenome_seq.xml +1 -0
- data/java/config/isa_configurator/nru_assay.xml +8 -0
- data/java/config/isa_configurator/ppi_detection_micro.xml +1 -0
- data/java/config/isa_configurator/protein_dna_binding_ident_micro.xml +1 -0
- data/java/config/isa_configurator/protein_dna_binding_ident_seq.xml +1 -0
- data/java/config/isa_configurator/protein_expression_ge.xml +101 -0
- data/java/config/isa_configurator/protein_expression_micro.xml +1 -0
- data/java/config/isa_configurator/protein_expression_ms.xml +1 -0
- data/java/config/isa_configurator/proteinident_ms.xml +1 -0
- data/java/config/isa_configurator/snpanalysis_micro.xml +1 -0
- data/java/config/isa_configurator/studySample.xml +1 -0
- data/java/config/isa_configurator/tfbsident_micro.xml +1 -0
- data/java/config/isa_configurator/tfbsident_seq.xml +1 -0
- data/java/config/isa_configurator/transcription_micro.xml +1 -0
- data/java/config/isa_configurator/transcription_rtpcr.xml +1 -0
- data/java/config/isa_configurator/transcription_seq.xml +6 -0
- data/test/Rakefile +48 -0
- data/test/all.rb +3 -0
- data/test/authorization.rb +112 -0
- data/test/basic_rest.rb +98 -0
- data/test/data/invalid/BII-invalid.n3 +19641 -0
- data/test/data/invalid/a_TB-ACCUTOX-plate1.txt +97 -0
- data/test/data/invalid/a_TB-ACCUTOX-plate2.txt +97 -0
- data/test/data/invalid/a_TB-ACCUTOX-plate3.txt +97 -0
- data/test/data/invalid/acetaminophen-plate1-data.txt +97 -0
- data/test/data/invalid/acetaminophen-plate2-data.txt +97 -0
- data/test/data/invalid/acetaminophen-plate3-data.txt +97 -0
- data/test/data/invalid/i_Investigation.txt +156 -0
- data/test/data/invalid/ic50.txt +20 -0
- data/test/data/invalid/isa_TB_ACCUTOX.xls +0 -0
- data/test/data/invalid/isa_TB_ACCUTOX.zip +0 -0
- data/test/data/invalid/s_TB-ACCUTOX-acetaminophen.txt +58 -0
- data/test/data/valid/BII-I-1.n3 +19648 -0
- data/test/data/valid/BII-I-1.rdf +19648 -0
- data/test/data/valid/BII-I-1.zip +0 -0
- data/test/data/valid/isa-tab-renamed.zip +0 -0
- data/test/data/valid/isa_TB_BII.xls +0 -0
- data/test/httpd.rb +69 -0
- data/test/querytest.rb +42 -0
- data/test/upload.rb +152 -0
- data/test/xls_upload.rb +60 -0
- data/toxbank-investigation.gemspec +29 -0
- metadata +133 -0
@@ -0,0 +1 @@
|
|
1
|
+
<isatab-config-file xmlns="http://www.ebi.ac.uk/bii/isatab_configuration#"><isatab-configuration table-name="transcription_micro" isatab-assay-type="transcriptomics_assay" isatab-conversion-target="magetab"><measurement term-label="transcription profiling" term-accession="0000424" source-abbreviation="OBI"/><technology term-label="DNA microarray" term-accession="0400148" source-abbreviation="OBI"/><field header="Sample Name" data-type="String" is-file-field="false" is-multiple-value="true" is-required="true" is-hidden="false"><description><![CDATA[Samples represent major outputs resulting from a protocol application other than the special case outputs of Extract or a Labeled Extract.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT]</generated-value-template></field><protocol-field protocol-type ="RNA extraction"/><field header="Extract Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[User-defined names for each portion of extracted material.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT]</generated-value-template></field><protocol-field protocol-type ="labeling"/><field header="Labeled Extract Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Identifier for the labeled extract.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT].LE-[LABEL_COUNT]</generated-value-template></field><field header="Label" data-type="Ontology term" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Indicates a chemical or biological marker, such as a radioactive isotope or a fluorescent dye which is bound to a material in order to make it detectable by some assay technology (e.g. P33, biotin, GFP).]]></description><default-value><![CDATA[]]></default-value><recommended-ontologies><ontology id="1007" abbreviation="CHEBI" name="Chemical entities of biological interest" version="45788"/></recommended-ontologies></field><protocol-field protocol-type ="nucleic acid hybridization"/><field header="Hybridization Assay Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[User-defined name for an assay.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT].LE-[LABEL_COUNT].HYB-[HYB_COUNT]</generated-value-template></field><field header="Array Design REF" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Reference to the identifier (or accession number) of an existing array design]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[ARRAY_DESIGN]</generated-value-template></field><protocol-field protocol-type ="data collection"/><field header="Scan Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[User-defined name for each scan event.]]></description><default-value><![CDATA[]]></default-value></field><field header="Image File" data-type="String" is-file-field="true" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[Name (or URI) of the image files generated by an assay]]></description><default-value><![CDATA[]]></default-value></field><field header="Array Data File" data-type="String" is-file-field="true" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Name (or URI) of the data file generated by an assay.]]></description><default-value><![CDATA[]]></default-value></field><field header="Array Data Matrix File" data-type="String" is-file-field="true" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[Name (or URI) of the raw array data matrix file.]]></description><default-value><![CDATA[]]></default-value></field><protocol-field protocol-type ="normalization data transformation"/><field header="Normalization Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[User-defined name for each normalization applied]]></description><default-value><![CDATA[]]></default-value></field><field header="Derived Array Data File" data-type="String" is-file-field="true" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[Name (or URI) of the data file generated by an assay.]]></description><default-value><![CDATA[]]></default-value></field><protocol-field protocol-type ="data transformation"/><field header="Data Transformation Name" data-type="String" is-file-field="false" is-multiple-value="true" is-required="false" is-hidden="false"><description><![CDATA[User-defined name for each data transformation applied]]></description><default-value><![CDATA[]]></default-value></field><field header="Derived Array Data Matrix File" data-type="String" is-file-field="true" is-multiple-value="true" is-required="false" is-hidden="false"><description><![CDATA[Name (or URI) of the processed data matrix file resulting from data transformation or processing.]]></description><default-value><![CDATA[]]></default-value></field><structured-field name="Factors"/></isatab-configuration></isatab-config-file>
|
@@ -0,0 +1 @@
|
|
1
|
+
<isatab-config-file xmlns="http://www.ebi.ac.uk/bii/isatab_configuration#"><isatab-configuration table-name="transcription_rtpcr" isatab-assay-type="generic_assay" isatab-conversion-target="generic"><measurement term-label="transcription profiling" term-accession="0000424" source-abbreviation="OBI"/><technology term-label="real time PCR" term-accession="" source-abbreviation="OBI"/><field header="Sample Name" data-type="String" is-file-field="false" is-multiple-value="true" is-required="true" is-hidden="false"><description><![CDATA[Samples represent major outputs resulting from a protocol application other than the special case outputs of Extract or a Labeled Extract.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT]</generated-value-template></field><protocol-field protocol-type ="nucleic acid extraction"/><field header="Extract Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[User-defined names for each portion of extracted material.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT]</generated-value-template></field><protocol-field protocol-type ="labeling"/><field header="Labeled Extract Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Identifier for the labeled extract.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT].LE-[LABEL_COUNT]</generated-value-template></field><field header="Label" data-type="Ontology term" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Indicates a chemical or biological marker, such as a radioactive isotope or a fluorescent dye which is bound to a material in order to make it detectable by some assay technology (e.g. P33, biotin, GFP).]]></description><default-value><![CDATA[]]></default-value><recommended-ontologies><ontology id="1007" abbreviation="CHEBI" name="Chemical entities of biological interest" version="40664"/></recommended-ontologies></field><protocol-field protocol-type ="reverse transcribed pcr"/><field header="Assay Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[User-defined name for an assay.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT].LE-[LABEL_COUNT].ASSAY-[HYB_COUNT]</generated-value-template></field><protocol-field protocol-type ="data collection"/><field header="Raw Data File" data-type="String" is-file-field="true" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Name (or URI) of the raw data file generated by an assay.]]></description><default-value><![CDATA[]]></default-value></field><protocol-field protocol-type ="data transformation"/><field header="Normalization Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[User-defined name for each normalization applied]]></description><default-value><![CDATA[]]></default-value></field><protocol-field protocol-type ="data transformation"/><field header="Data Transformation Name" data-type="String" is-file-field="false" is-multiple-value="true" is-required="false" is-hidden="false"><description><![CDATA[User-defined name for each data transformation applied]]></description><default-value><![CDATA[]]></default-value></field><field header="Derived Data File" data-type="String" is-file-field="true" is-multiple-value="true" is-required="false" is-hidden="false"><description><![CDATA[Name (or URI) of the data file generated by an assay.]]></description><default-value><![CDATA[]]></default-value></field><structured-field name="Factors"/></isatab-configuration></isatab-config-file>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<isatab-config-file xmlns="http://www.ebi.ac.uk/bii/isatab_configuration#"><isatab-configuration table-name="transcription_seq" isatab-assay-type="generic_assay" isatab-conversion-target="sra"><measurement term-label="transcription profiling" term-accession="0000424" source-abbreviation="OBI"/><technology term-label="nucleotide sequencing" term-accession="" source-abbreviation="OBI"/><field header="Sample Name" data-type="String" is-file-field="false" is-multiple-value="true" is-required="true" is-hidden="false"><description><![CDATA[Samples represent major outputs resulting from a protocol application other than the special case outputs of Extract or a Labeled Extract.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT]
|
2
|
+
</generated-value-template></field><protocol-field protocol-type ="nucleic acid extraction"/><field header="Extract Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[User-defined names for each portion of extracted material.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>
|
3
|
+
[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT]
|
4
|
+
</generated-value-template></field><protocol-field protocol-type ="library construction"/><field header="Parameter Value[library layout]" data-type="List" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[specifies whether to expect single, paired, or other configuration of reads.]]></description><default-value><![CDATA[]]></default-value><list-values>SINGLE,PAIRED</list-values></field><field header="Parameter Value[mid]" data-type="String" is-file-field="false" is-multiple-value="true" is-required="false" is-hidden="false"><description><![CDATA['mid' stands for 'multiplex identifier' (aka barcode tag). Use this field when performing a multiplexing procedure and indicate here the nucleic acid tag used to uniquely identify the sample if the pool.]]></description><default-value><![CDATA[]]></default-value></field><protocol-field protocol-type ="nucleic acid sequencing"/><field header="Parameter Value[sequencing instrument]" data-type="List" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[a parameter to report the sequencing instrument model and make]]></description><default-value><![CDATA[]]></default-value><list-values>454 GS,454 GS 20,454 GS FLX,454 GS FLX Titanium,454 GS Junior,GS 20,GS FLX,AB SOLiD System,AB SOLiD System 2.0,AB SOLiD System 3.0,AB SOLiD 4 System,AB SOLiD 4hq System,AB SOLiD PI System,Solexa 1G Genome Analyzer,Illumina Genome Analyzer,Illumina Genome Analyzer II,Illumina Genome Analyzer IIx,Illumina HiSeq 2000,Sanger sequencing instrument</list-values></field><field header="Parameter Value[base caller]" data-type="String" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[Name and version of the base or color calling software.]]></description><default-value><![CDATA[]]></default-value></field><field header="Parameter Value[quality score]" data-type="String" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[Name and version of the quality scoring software.]]></description><default-value><![CDATA[]]></default-value></field><field header="Assay Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[User-defined name for an assay.]]></description><default-value><![CDATA[]]></default-value><generated-value-template>
|
5
|
+
[INSTITUTION].Group-[GROUP_NO].Subject-[SUBJECT_NO].[SAMPLE_EXTRACT].Extract-[EXTRACT_COUNT].LE-[LABEL_COUNT].ASSAY-[HYB_COUNT]
|
6
|
+
</generated-value-template></field><field header="Comment[Export]" data-type="List" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[Use this field to select/set which records should be exported for a submission to SRA/ENA]]></description><default-value><![CDATA[no]]></default-value><list-values>yes,no</list-values></field><field header="Raw Data File" data-type="String" is-file-field="true" is-multiple-value="false" is-required="true" is-hidden="false"><description><![CDATA[Name (or URI) of the raw data file generated by an assay.]]></description><default-value><![CDATA[]]></default-value></field><protocol-field protocol-type ="sequence analysis data transformation"/><field header="Normalization Name" data-type="String" is-file-field="false" is-multiple-value="false" is-required="false" is-hidden="false"><description><![CDATA[User-defined name for each normalization applied]]></description><default-value><![CDATA[]]></default-value></field><field header="Data Transformation Name" data-type="String" is-file-field="false" is-multiple-value="true" is-required="false" is-hidden="false"><description><![CDATA[User-defined name for each data transformation applied]]></description><default-value><![CDATA[]]></default-value></field><field header="Derived Data File" data-type="String" is-file-field="true" is-multiple-value="true" is-required="false" is-hidden="false"><description><![CDATA[Name (or URI) of the data file generated by an assay.]]></description><default-value><![CDATA[]]></default-value></field><structured-field name="Factors"/></isatab-configuration></isatab-config-file>
|
data/test/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'opentox-server'
|
3
|
+
#require File.join(File.dirname(__FILE__),"../lib/toxbank-investigation.rb")
|
4
|
+
#['otlogger', 'environment', 'helper'].each do |lib|
|
5
|
+
#require '../lib/' + lib
|
6
|
+
#end
|
7
|
+
|
8
|
+
HOST = "http://localhost/"
|
9
|
+
AA_SERVER = "https://opensso.in-silico.ch"
|
10
|
+
TEST_USER = "guest"
|
11
|
+
TEST_PW = "guest"
|
12
|
+
|
13
|
+
=begin
|
14
|
+
task ARGV[0] do
|
15
|
+
puts "Environment: #{ENV["RACK_ENV"]}"
|
16
|
+
ARGV[0] = ARGV[0].gsub(/\.rb$/,"")
|
17
|
+
puts "Test: "+ARGV[0]+".rb"
|
18
|
+
puts File.join(File.dirname(__FILE__),ARGV[0]+".rb")
|
19
|
+
#require File.join(File.dirname(__FILE__),ARGV[0]+".rb")
|
20
|
+
require "./"+ARGV[0]+".rb"
|
21
|
+
end
|
22
|
+
=end
|
23
|
+
|
24
|
+
task ARGV[0] do
|
25
|
+
puts "Environment: #{ENV["RACK_ENV"]}"
|
26
|
+
ARGV[0] = ARGV[0].gsub(/\.rb$/,"")
|
27
|
+
puts "Test: "+ARGV[0]+".rb"
|
28
|
+
require "./"+ARGV[0]+".rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
task :setup do
|
32
|
+
# setup code
|
33
|
+
if AA_SERVER
|
34
|
+
resource = RestClient::Resource.new("#{AA_SERVER}/auth/authenticate")
|
35
|
+
@@subjectid = resource.post(:username=>TEST_USER, :password => TEST_PW).sub("token.id=","").sub("\n","")
|
36
|
+
else
|
37
|
+
@@subjectid = ""
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :teardown do
|
42
|
+
# teardown code
|
43
|
+
end
|
44
|
+
|
45
|
+
[:all, :upload, :basic_rest, :xls_upload, :querytest, :authorization, :httpd].each do |t|
|
46
|
+
task :teardown => t
|
47
|
+
task t => :setup
|
48
|
+
end
|
data/test/all.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
#require "opentox-ruby"
|
3
|
+
require "test/unit"
|
4
|
+
|
5
|
+
TEST_URI = "http://only_a_test/test/" + rand(1000000).to_s
|
6
|
+
unless AA_SERVER #overwrite turned off A&A server for testing
|
7
|
+
AA_SERVER = "https://opensso.in-silico.ch"
|
8
|
+
@@subjectid = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW)
|
9
|
+
end
|
10
|
+
|
11
|
+
class TestOpenToxAuthorizationBasic < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def test_01_server
|
14
|
+
@aaserver = AA_SERVER
|
15
|
+
assert_equal(@aaserver, OpenTox::Authorization.server)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_02_get_token
|
19
|
+
assert_not_nil @@subjectid
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_03_is_valid_token
|
23
|
+
tok = login
|
24
|
+
assert_not_nil tok
|
25
|
+
assert OpenTox::Authorization.is_token_valid(tok)
|
26
|
+
logout(tok)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_04_logout
|
30
|
+
tok = login
|
31
|
+
assert logout(tok)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_05_list_policies
|
35
|
+
assert_kind_of Array, OpenTox::Authorization.list_policies(@@subjectid)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
class TestOpenToxAuthorizationLDAP < Test::Unit::TestCase
|
41
|
+
|
42
|
+
def test_01_list_groups
|
43
|
+
assert_kind_of Array, OpenTox::Authorization.list_groups(@@subjectid)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_02_list_user_groups
|
47
|
+
assert_kind_of Array, OpenTox::Authorization.list_user_groups(TEST_USER, @@subjectid)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_03_get_user
|
51
|
+
assert_equal TEST_USER, OpenTox::Authorization.get_user(@@subjectid)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
class TestOpenToxAuthorizationLDAP < Test::Unit::TestCase
|
57
|
+
|
58
|
+
def test_01_create_check_delete_default_policies
|
59
|
+
res = OpenTox::Authorization.send_policy(TEST_URI, @@subjectid)
|
60
|
+
assert res
|
61
|
+
assert OpenTox::Authorization.uri_has_policy(TEST_URI, @@subjectid)
|
62
|
+
policies = OpenTox::Authorization.list_uri_policies(TEST_URI, @@subjectid)
|
63
|
+
assert_kind_of Array, policies
|
64
|
+
policies.each do |policy|
|
65
|
+
assert OpenTox::Authorization.delete_policy(policy, @@subjectid)
|
66
|
+
end
|
67
|
+
assert_equal false, OpenTox::Authorization.uri_has_policy(TEST_URI, @@subjectid)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_02_check_policy_rules
|
71
|
+
tok_anonymous = OpenTox::Authorization.authenticate("anonymous","anonymous")
|
72
|
+
assert_not_nil tok_anonymous
|
73
|
+
res = OpenTox::Authorization.send_policy(TEST_URI, @@subjectid)
|
74
|
+
assert res
|
75
|
+
assert OpenTox::Authorization.uri_has_policy(TEST_URI, @@subjectid)
|
76
|
+
owner_rights = {"GET" => true, "POST" => true, "PUT" => true, "DELETE" => true}
|
77
|
+
groupmember_rights = {"GET" => true, "POST" => nil, "PUT" => nil, "DELETE" => nil}
|
78
|
+
owner_rights.each do |request, right|
|
79
|
+
assert_equal right, OpenTox::Authorization.authorize(TEST_URI, request, @@subjectid), "#{TEST_USER} requests #{request} to #{TEST_URI}"
|
80
|
+
end
|
81
|
+
groupmember_rights.each do |request, r|
|
82
|
+
assert_equal r, OpenTox::Authorization.authorize(TEST_URI, request, tok_anonymous), "anonymous requests #{request} to #{TEST_URI}"
|
83
|
+
end
|
84
|
+
|
85
|
+
policies = OpenTox::Authorization.list_uri_policies(TEST_URI, @@subjectid)
|
86
|
+
assert_kind_of Array, policies
|
87
|
+
policies.each do |policy|
|
88
|
+
assert OpenTox::Authorization.delete_policy(policy, @@subjectid)
|
89
|
+
end
|
90
|
+
logout(tok_anonymous)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_03_check_different_uris
|
94
|
+
res = OpenTox::Authorization.send_policy(TEST_URI, @@subjectid)
|
95
|
+
assert OpenTox::Authorization.uri_has_policy(TEST_URI, @@subjectid)
|
96
|
+
assert OpenTox::Authorization.authorize(TEST_URI, "GET", @@subjectid), "GET request"
|
97
|
+
policies = OpenTox::Authorization.list_uri_policies(TEST_URI, @@subjectid)
|
98
|
+
policies.each do |policy|
|
99
|
+
assert OpenTox::Authorization.delete_policy(policy, @@subjectid)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def logout (token)
|
107
|
+
OpenTox::Authorization.logout(token)
|
108
|
+
end
|
109
|
+
|
110
|
+
def login
|
111
|
+
OpenTox::Authorization.authenticate(TEST_USER,TEST_PW)
|
112
|
+
end
|
data/test/basic_rest.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
HOST = "http://localhost/"
|
7
|
+
AA_SERVER = "https://opensso.in-silico.ch"
|
8
|
+
TEST_USER = "guest"
|
9
|
+
TEST_PW = "guest"
|
10
|
+
resource = RestClient::Resource.new("#{AA_SERVER}/auth/authenticate")
|
11
|
+
@@subjectid = resource.post(:username=>TEST_USER, :password => TEST_PW).sub("token.id=","").sub("\n","")
|
12
|
+
|
13
|
+
class BasicTest < Test::Unit::TestCase
|
14
|
+
|
15
|
+
# check response from service
|
16
|
+
def test_01_get_investigations_200
|
17
|
+
response = RestClient.get HOST,:subjectid => @@subjectid
|
18
|
+
assert_equal 200, response.code
|
19
|
+
end
|
20
|
+
|
21
|
+
# check if default response header is text/uri-list
|
22
|
+
def test_02_get_investigations_type
|
23
|
+
response = RestClient.get HOST, { :subjectid => @@subjectid }
|
24
|
+
assert_equal "text/uri-list", response.headers[:content_type]
|
25
|
+
end
|
26
|
+
|
27
|
+
# check sparql query call to all investigations
|
28
|
+
def test_03_get_investigations_query
|
29
|
+
response = nil
|
30
|
+
Net::HTTP.get_response(URI(File.join(HOST, "?query=bla&subjectid=#{CGI.escape(@@subjectid)}"))) {|http|
|
31
|
+
response = http
|
32
|
+
}
|
33
|
+
assert_equal 200, response.code.to_i
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
class BasicTestCRUDInvestigation < Test::Unit::TestCase
|
39
|
+
|
40
|
+
# check post to investigation service with wrong content type
|
41
|
+
def test_01_post_investigation_400
|
42
|
+
uri = URI(File.join(HOST, 'investigation'))
|
43
|
+
req = Net::HTTP::Post.new("#{uri.path}?subjectid=#{CGI.escape(@@subjectid)}")
|
44
|
+
req.content_type = "text/dummy"
|
45
|
+
res = Net::HTTP.start(uri.host, uri.port) do |http|
|
46
|
+
http.request(req)
|
47
|
+
end
|
48
|
+
assert_equal 400, res.code.to_i
|
49
|
+
end
|
50
|
+
|
51
|
+
# create an investigation by uploading a zip file
|
52
|
+
def test_02_post_investigation
|
53
|
+
@@uri = ""
|
54
|
+
result = `curl -X POST #{HOST} -H "Content-Type: multipart/form-data" -F "file=@data/valid/BII-I-1.zip;type=application/zip" -H "subjectid:#{@@subjectid}"`
|
55
|
+
puts result
|
56
|
+
@@uri = URI(result)
|
57
|
+
assert @@uri.host == URI(HOST).host
|
58
|
+
end
|
59
|
+
|
60
|
+
# get investigation/{id} as text/uri-list
|
61
|
+
def test_03_get_investigation_uri_list
|
62
|
+
result = RestClient.get @@uri.to_s, {:Accept => "text/uri-list", :subjectid => @@subjectid}
|
63
|
+
assert_equal "text/uri-list", result.headers[:content_type]
|
64
|
+
end
|
65
|
+
|
66
|
+
# get investigation/{id} as application/zip
|
67
|
+
def test_04_get_investigation_zip
|
68
|
+
result = RestClient.get @@uri.to_s, {:Accept => "application/zip", :subjectid => @@subjectid}
|
69
|
+
assert_equal "application/zip", result.headers[:content_type]
|
70
|
+
end
|
71
|
+
|
72
|
+
# get investigation/{id} as text/tab-separated-values
|
73
|
+
def test_05_get_investigation_tab
|
74
|
+
result = RestClient.get @@uri.to_s, {:Accept => "text/tab-separated-values", :subjectid => @@subjectid}
|
75
|
+
assert_equal "text/tab-separated-values;charset=utf-8", result.headers[:content_type]
|
76
|
+
end
|
77
|
+
|
78
|
+
# get investigation/{id} as application/sparql-results+json
|
79
|
+
def test_06_get_investigation_sparql
|
80
|
+
result = RestClient.get @@uri.to_s, {:Accept => "application/sparql-results+json", :subjectid => @@subjectid}
|
81
|
+
assert_equal "application/sparql-results+json", result.headers[:content_type]
|
82
|
+
end
|
83
|
+
|
84
|
+
# check if uri is in uri-list
|
85
|
+
def test_98_get_investigation
|
86
|
+
response = RestClient.get HOST, :subjectid => @@subjectid
|
87
|
+
assert response.index(@@uri.to_s) != nil, "URI: #{@@uri} is not in uri-list"
|
88
|
+
end
|
89
|
+
|
90
|
+
# delete investigation/{id}
|
91
|
+
def test_99_delete_investigation
|
92
|
+
result = RestClient.delete @@uri.to_s, :subjectid => @@subjectid
|
93
|
+
assert result.match(/^investigation.[0-9]*.deleted$/)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|