modify auth to chaincode

parent e0ae72a9
......@@ -3,7 +3,8 @@
<component name="ChangeListManager">
<list default="true" id="de83b181-e854-4be8-81f5-73a2fdb02762" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gongxianghui/gongxianghui.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui.go" beforeDir="false" afterPath="$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui_test.go" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -12,11 +13,73 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui/gongxianghui.go">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="579">
<caret line="544" column="21" lean-forward="true" selection-start-line="544" selection-start-column="21" selection-end-line="544" selection-end-column="21" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file:///usr/local/go/src/builtin/builtin.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="664">
<caret line="259" column="5" selection-start-line="259" selection-start-column="5" selection-end-line="259" selection-end-column="5" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file:///usr/local/go/src/fmt/errors.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="295">
<caret line="16" column="5" selection-start-line="16" selection-start-column="5" selection-end-line="16" selection-end-column="5" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file:///usr/local/go/src/encoding/json/decode.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2352">
<caret line="94" column="5" selection-start-line="94" selection-start-column="5" selection-end-line="94" selection-end-column="5" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1175">
<caret line="16" column="26" selection-start-line="16" selection-start-column="26" selection-end-line="16" selection-end-column="26" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file:///usr/local/go/src/time/time.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="32116">
<caret line="1150" column="14" selection-start-line="1150" selection-start-column="14" selection-end-line="1150" selection-end-column="14" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>user</find>
<find>stub.GetState</find>
<find>stub.PutState</find>
</findStrings>
</component>
<component name="GOROOT" path="/usr/local/go" />
......@@ -34,6 +97,7 @@
<option value="$PROJECT_DIR$/github.com/gongxianghui_test/gongxianghui_test.go" />
<option value="$PROJECT_DIR$/github.com/gongxianghui/gongxianghui.go" />
<option value="$PROJECT_DIR$/github.com/gongxianghui_test/gongxianghui.go" />
<option value="$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui_test.go" />
<option value="$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui.go" />
</list>
</option>
......@@ -50,6 +114,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -57,6 +122,31 @@
<item name="chaincode" type="b2602c69:ProjectViewProjectNode" />
<item name="chaincode" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="chaincode" type="b2602c69:ProjectViewProjectNode" />
<item name="chaincode" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="chaincode" type="b2602c69:ProjectViewProjectNode" />
<item name="chaincode" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="github.com" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="chaincode" type="b2602c69:ProjectViewProjectNode" />
<item name="chaincode" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="github.com" type="462c0819:PsiDirectoryNode" />
<item name="gongxianghui" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="chaincode" type="b2602c69:ProjectViewProjectNode" />
<item name="chaincode" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="github.com" type="462c0819:PsiDirectoryNode" />
<item name="gongxianghui_auth" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="chaincode" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
......@@ -65,7 +155,6 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
......@@ -91,7 +180,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Go Test.TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test">
<component name="RunManager" selected="Go Test.TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth">
<configuration name="TestGXH in github.com/hyperledger/chaincode/github.com/gongxianghui" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="chaincode" />
<working_directory value="$PROJECT_DIR$/github.com/gongxianghui" />
......@@ -114,34 +203,34 @@
<pattern value="^TestGXHDataPutAuth$" />
<method v="2" />
</configuration>
<configuration name="TestGXHSchema in github.com/hyperledger/chaincode/github.com/gongxianghui" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="chaincode" />
<working_directory value="$PROJECT_DIR$/github.com/gongxianghui" />
<working_directory value="$PROJECT_DIR$/src/github.com/gongxianghui_auth" />
<framework value="gotest" />
<kind value="PACKAGE" />
<package value="github.com/hyperledger/chaincode/github.com/gongxianghui" />
<package value="github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" />
<directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" />
<pattern value="^TestGXHSchema$" />
<pattern value="^TestGXHDataPutAuth$" />
<method v="2" />
</configuration>
<configuration name="TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="chaincode" />
<working_directory value="$PROJECT_DIR$/gongxianghui" />
<working_directory value="$PROJECT_DIR$/github.com/gongxianghui_test" />
<framework value="gotest" />
<kind value="PACKAGE" />
<package value="github.com/hyperledger/chaincode/gongxianghui" />
<package value="github.com/hyperledger/chaincode/github.com/gongxianghui_test" />
<directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" />
<pattern value="^TestGXHSchema$" />
<pattern value="^TestGXHSchemaAuth$" />
<method v="2" />
</configuration>
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="chaincode" />
<working_directory value="$PROJECT_DIR$/github.com/gongxianghui_test" />
<working_directory value="$PROJECT_DIR$/src/github.com/gongxianghui_auth" />
<framework value="gotest" />
<kind value="PACKAGE" />
<package value="github.com/hyperledger/chaincode/github.com/gongxianghui_test" />
<package value="github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" />
<directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" />
<pattern value="^TestGXHSchemaAuth$" />
......@@ -149,55 +238,56 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Test.TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" />
<item itemvalue="Go Test.TestGXHSchemaAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" />
<item itemvalue="Go Test.TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" />
<item itemvalue="Go Test.TestGXHSchemaAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" />
<item itemvalue="Go Test.TestGXH in github.com/hyperledger/chaincode/github.com/gongxianghui" />
<item itemvalue="Go Test.TestGXHSchema in github.com/hyperledger/chaincode/github.com/gongxianghui" />
<item itemvalue="Go Test.TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui" />
</list>
</recent_temporary>
</component>
<component name="TestHistory">
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 11h 58m 38s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHSchemaAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 08m 13s.xml">
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 15h 36m 05s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 09m 18s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 15h 36m 55s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHSchemaAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 10m 13s.xml">
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 15h 37m 25s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHSchemaAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 16m 19s.xml">
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 15h 38m 00s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHSchemaAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 16m 56s.xml">
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 15h 39m 54s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHSchemaAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 18m 19s.xml">
<configuration name="TestGXHSchemaAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 15h 40m 19s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 18m 43s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 15h 40m 45s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 19m 40s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 16h 14m 06s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 20m 06s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_github_com_gongxianghui_test - 2020.02.27 at 18h 22m 13s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/github.com/gongxianghui_test" configurationId="GoTestRunConfiguration" />
<history-entry file="TestGXHDataPutAuth_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_auth - 2020.02.29 at 22h 20m 41s.xml">
<configuration name="TestGXHDataPutAuth in github.com/hyperledger/chaincode/src/github.com/gongxianghui_auth" configurationId="GoTestRunConfiguration" />
</history-entry>
</component>
<component name="ToolWindowManager">
<frame x="71" y="32" width="2489" height="1568" extended-state="6" />
<frame x="71" y="31" width="2489" height="1569" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.21466611" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.21701603" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.32962447" />
<window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.32909605" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39986092" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
......@@ -206,7 +296,7 @@
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info anchor="bottom" id="Database Changes" order="9" />
<window_info anchor="bottom" id="Statistic" order="10" />
<window_info anchor="bottom" id="Terminal" order="11" visible="true" weight="0.31223923" />
<window_info anchor="bottom" id="Terminal" order="11" weight="0.31223923" />
<window_info anchor="bottom" id="Event Log" order="12" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
......@@ -218,6 +308,18 @@
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui.go</url>
<line>529</line>
<properties />
<option name="timeStamp" value="22" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/gongxianghui/schema.go" />
<entry file="file://$PROJECT_DIR$/gongxianghui/deposit.go" />
......@@ -244,13 +346,6 @@
</state>
</provider>
</entry>
<entry file="file:///usr/local/go/src/fmt/errors.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="211">
<caret line="16" column="5" selection-start-line="16" selection-start-column="5" selection-end-line="16" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file:///usr/local/go/src/crypto/x509/pkix/pkix.go">
<provider selected="true" editor-type-id="text-editor">
<state>
......@@ -279,52 +374,59 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui_auth/gongxianghui_test.go">
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui_auth/gongxianghui_test.go" />
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui/gongxianghui_test.go" />
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui/gongxianghui.go" />
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui_auth/gongxianghui.go" />
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/interfaces.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1276">
<caret line="164" column="70" selection-start-line="164" selection-start-column="70" selection-end-line="164" selection-end-column="70" />
<state relative-caret-position="880">
<caret line="44" column="4" selection-start-line="44" selection-start-column="4" selection-end-line="44" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui/gongxianghui_test.go">
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui/gongxianghui.go">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file:///usr/local/go/src/encoding/json/decode.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="462">
<caret line="37" selection-start-line="37" selection-end-line="37" />
<state relative-caret-position="2352">
<caret line="94" column="5" selection-start-line="94" selection-start-column="5" selection-end-line="94" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui/gongxianghui.go">
<entry file="file:///usr/local/go/src/time/time.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="519">
<caret line="90" column="83" selection-start-line="90" selection-start-column="78" selection-end-line="90" selection-end-column="83" />
<state relative-caret-position="32116">
<caret line="1150" column="14" selection-start-line="1150" selection-start-column="14" selection-end-line="1150" selection-end-column="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/github.com/gongxianghui_auth/gongxianghui.go">
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-7612">
<caret line="107" column="83" selection-start-line="107" selection-start-column="83" selection-end-line="107" selection-end-column="83" />
<state relative-caret-position="-1175">
<caret line="16" column="26" selection-start-line="16" selection-start-column="26" selection-end-line="16" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui_test.go">
<entry file="file:///usr/local/go/src/builtin/builtin.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="418">
<caret line="107" column="4" selection-start-line="107" selection-start-column="4" selection-end-line="119" selection-end-column="66" />
<state relative-caret-position="664">
<caret line="259" column="5" selection-start-line="259" selection-start-column="5" selection-end-line="259" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui.go">
<entry file="file:///usr/local/go/src/fmt/errors.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="396">
<caret line="26" column="61" selection-start-line="26" selection-start-column="4" selection-end-line="26" selection-end-column="61" />
<state relative-caret-position="295">
<caret line="16" column="5" selection-start-line="16" selection-start-column="5" selection-end-line="16" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/interfaces.go">
<entry file="file://$PROJECT_DIR$/src/github.com/gongxianghui_auth/gongxianghui.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="880">
<caret line="44" column="4" selection-start-line="44" selection-start-column="4" selection-end-line="44" selection-end-column="4" />
<state relative-caret-position="579">
<caret line="544" column="21" lean-forward="true" selection-start-line="544" selection-start-column="21" selection-end-line="544" selection-end-column="21" />
</state>
</provider>
</entry>
......
......@@ -8,29 +8,39 @@ import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
"time"
)
type GXHCC struct {
}
//type Schema struct {
//}
type AuthGroup struct {
Users map[string]int64 `json:"users"` //用户组权限,默认使用用户组。我们使用形如:“User1”:timestamp. key 表示用户或者角色,value 表示有效时间。我们使用格林威治时间时间戳
Roles map[string]int64 `json:"roles"` //角色组权限,
}
type Auth struct {
Read AuthGroup `json:"read"` // 字段的读权限,“”,不存在权限,
Write AuthGroup `json:"write"`//字段的写权限
}
type SchemaParameters struct {
Value interface{} //默认值 这里特别说明一下如果这里是backUp 字段,我们不进行更深一步的校验,包括格式
Read []string // 字段的读权限,“”,不存在权限,
Write []string //字段的写权限
Value interface{} `json:"val"`//默认值 这里特别说明一下如果这里是backUp 字段,我们不进行更深一步的校验,包括格式
PAuth Auth `json:"auth"`
}
type Schema struct {
Parameters map[string]SchemaParameters
SchemaWrite []string //schema 的写权限,主要是用在 schema update 部分
Read []string
Write []string
Fields map[string]SchemaParameters `json:"fields"`
SchemaAuth Auth `json:"schema_auth"`//schema 的写权限,主要是用在 schema update 部分
SAuth Auth `json:"auth"`
}
var (
defValue = "***" //查询用户权限不足的情况下默认返回值
PREFIX = "GXH"
IsUsers = false //是否启用用户权限,false 表示启用Roles
)
// Init does nothing for this cc
......@@ -89,7 +99,7 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if len(args) < 2 {
return "", fmt.Errorf("Expected more than 2 parameters to function put!")
}
var Result []map[string]interface{}
var PutDatas []map[string]interface{}
commonName, err := getCertificateCommonName(stub)
if err != nil {
return "", fmt.Errorf("getCertificateCommonName happen err: %s ", err)
......@@ -102,13 +112,13 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if err := json.Unmarshal([]byte(result), &schema); err != nil {
return "", fmt.Errorf("json Unmarshal schemaRes err: %s ", err)
}
if !authorityCheck(schema.Write, commonName) {
return "", fmt.Errorf("The current user does not have write permission to %s ", args[0])
if ok,err := authorityCheck(schema.SAuth.Write, commonName);!ok {
return "", fmt.Errorf("write %s table fail,err: %s ", args[0],err)
}
if err := json.Unmarshal([]byte(args[1]), &Result); err != nil {
if err := json.Unmarshal([]byte(args[1]), &PutDatas); err != nil {
return "", fmt.Errorf("parameters Unmarshal fail,args string not json array, err:%s", err)
}
for k, mapres := range Result {
for k, mapres := range PutDatas {
Id, ok := mapres["id"]
if !ok {
return "", fmt.Errorf("The id field must exist ")
......@@ -119,11 +129,11 @@ func put(args []string, stub shim.ChaincodeStubInterface) (string, error) {
//else if result != nil {
// return "", fmt.Errorf("%s data already exist", args[0]+Id.(string))
//}
if !SchemaCheck(schema.Parameters, mapres) {
if !SchemaCheck(schema.Fields, mapres) {
return "", fmt.Errorf("SchemaCheck fail,args index %d string doesn't match %s format", k, args[0])
}
putDate, _ := json.Marshal(mapres)
if err := stub.PutState(args[0]+Id.(string), putDate); err != nil {
if err := stub.PutState(PREFIX+"_"+args[0]+"_"+Id.(string), putDate); err != nil {
return "", fmt.Errorf("PutState fail, err :%s", err)
}
}
......@@ -149,33 +159,33 @@ func update(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if err := json.Unmarshal([]byte(schemaRes), &schema); err != nil {
return "", fmt.Errorf("json Unmarshal schemaRes err: %s ", err)
}
var mapResult map[string]interface{}
var Updata map[string]interface{}
var allMap map[string]interface{}
if err := json.Unmarshal([]byte(args[1]), &mapResult); err != nil {
if err := json.Unmarshal([]byte(args[1]), &Updata); err != nil {
return "", fmt.Errorf("parameters Unmarshal fail,args string not json string,err: %s", err)
}
Id, ok := mapResult["id"]
Id, ok := Updata["id"]
if !ok {
return "", fmt.Errorf("The id field must exist ")
}
if !authorityCheck(schema.Write, commonName) {
if ok, err := parsauthorityCheck(schema.Parameters, mapResult, commonName); !ok {
if ok ,_ := authorityCheck(schema.SAuth.Write, commonName);!ok {
if ok, err := parsauthorityCheck(schema.Fields, Updata, commonName); !ok {
return "", fmt.Errorf("parsauthorityCheck err: %s", err)
}
}
result, err := stub.GetState(args[0] + Id.(string))
result, err := stub.GetState(PREFIX+"_"+args[0]+"_"+Id.(string))
if err != nil || result == nil {
return "", fmt.Errorf("GetState data fail,please check your parameters ")
}
if err := json.Unmarshal(result, &allMap); err != nil {
return "", fmt.Errorf("result parameters Unmarshal fail err:%s ", err)
}
if err := Deassign(mapResult, allMap); err != nil {
if err := Deassign(Updata, allMap); err != nil {
return "", err
}
resultByte, _ := json.Marshal(allMap)
if err := stub.PutState(args[0]+Id.(string), resultByte); err != nil {
if err := stub.PutState(PREFIX+"_"+args[0]+"_"+Id.(string), resultByte); err != nil {
return "", fmt.Errorf("updateState date fail, err :%s ", err)
}
return fmt.Sprintf("%s update data success!", args[0]), nil
......@@ -201,7 +211,7 @@ func get(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if !ok {
return "", fmt.Errorf("The id field must exist ")
}
result, err := stub.GetState(args[0] + Id.(string))
result, err := stub.GetState(PREFIX+"_"+args[0]+"_"+Id.(string))
if err != nil || result == nil {
return "", fmt.Errorf("GetState data fail,please check your parameters ")
}
......@@ -216,8 +226,8 @@ func get(args []string, stub shim.ChaincodeStubInterface) (string, error) {
if err := json.Unmarshal(result, &mapResult); err != nil {
return "", fmt.Errorf(" Unmarshal fail,result err: %s", err)
}
if !authorityCheck(schema.Read, commonName) {
if filteredData, err := dataFilter(schema.Parameters, mapResult, commonName); err != nil {
if ok,_:= authorityCheck(schema.SAuth.Read, commonName);!ok {
if filteredData, err := dataFilter(schema.Fields, mapResult, commonName); err != nil {
return "", fmt.Errorf(" dataFilter fail, err: %s", err)
} else {
result, _ := json.Marshal(filteredData)
......@@ -313,7 +323,7 @@ func SchemaProcess(args []string, stub shim.ChaincodeStubInterface) (string, err
case "update":
return schema.update(args[1:], stub)
case "get":
return schema.get(args[1], stub)
return schema.getSchema(args[1], stub)
default:
return "", fmt.Errorf(fmt.Sprintf("Unsupported schema function of %s", args[0]))
......@@ -338,7 +348,7 @@ func (this *Schema) put(args []string, stub shim.ChaincodeStubInterface) (string
if err := json.Unmarshal([]byte(args[1]), &schema); err != nil {
return "", fmt.Errorf("parameters Unmarshal fail,args string not json string,err: %s", err)
} else {
if backupValue, ok := schema.Parameters["backup"]; ok {
if backupValue, ok := schema.Fields["backup"]; ok {
if _,ok := backupValue.Value.(map[string]interface{}); !ok {
return "", fmt.Errorf("parameters Unmarshal fail,extra string not json string,err: %s", err)
}
......@@ -349,15 +359,15 @@ func (this *Schema) put(args []string, stub shim.ChaincodeStubInterface) (string
//}
}
}
_, ok := schema.Parameters["id"]
_, ok := schema.Fields["id"]
if !ok {
return "", fmt.Errorf("The id field must exist ")
}
if value, _ := stub.GetState(args[0]); value != nil {
if value, _ := stub.GetState(PREFIX+"_"+args[0]); value != nil {
return "", fmt.Errorf("the parameter %s already exists and cannot be added", args[0])
}
putDate, _ := json.Marshal(schema) //处理重复字段
if err := stub.PutState(args[0], putDate); err != nil {
if err := stub.PutState(PREFIX+"_"+args[0], putDate); err != nil {
return "", fmt.Errorf("PutState fail,err: %s", err)
}
return fmt.Sprintf("%s schema put success!", args[0]), nil
......@@ -377,17 +387,17 @@ func (this *Schema) update(args []string, stub shim.ChaincodeStubInterface) (str
if err := json.Unmarshal([]byte(args[1]), &schema); err != nil {
return "", fmt.Errorf("parameters Unmarshal fail,args string not json string,err: %s", err)
} else {
if backupValue, ok := schema.Parameters["backup"]; ok { //保证backup 对应的参数格式为map[string]interface{}
if backupValue, ok := schema.Fields["backup"]; ok { //保证backup 对应的参数格式为map[string]interface{}
if _,ok := backupValue.Value.(map[string]interface{}); !ok {
return "", fmt.Errorf("parameters Unmarshal fail,extra string not json string,err: %s", err)
}
}
}
_, ok := schema.Parameters["id"]
_, ok := schema.Fields["id"]
if !ok {
return "", fmt.Errorf("The id field must exist ")
}
result, err := stub.GetState(args[0])
result, err := stub.GetState(PREFIX+"_"+args[0])
if err != nil || result == nil {
return "", fmt.Errorf("%s schema data doesn't exist,please check your parameters ",args[0])
}
......@@ -399,10 +409,10 @@ func (this *Schema) update(args []string, stub shim.ChaincodeStubInterface) (str
if err != nil {
return "", fmt.Errorf("getCertificateCommonName happen err: %s ", err)
}
if !authorityCheck(schema.SchemaWrite,commonName){
return "", fmt.Errorf("The current user does not have update permission to %s schema ", args[0])
if ok,err := authorityCheck(schema.SchemaAuth.Write,commonName);!ok{
return "", fmt.Errorf("update %s schema fail,err: %s ",args[0],err)
}
if err = stub.PutState(args[0], []byte(args[1]));err != nil{
if err = stub.PutState(PREFIX+"_"+args[0], []byte(args[1]));err != nil{
return "", fmt.Errorf("%s schema data PutState fail,please try again ",args[0])
}
return fmt.Sprintf("%s schema update success!", args[0]), err
......@@ -410,10 +420,28 @@ func (this *Schema) update(args []string, stub shim.ChaincodeStubInterface) (str
}
func (this *Schema) get(args string, stub shim.ChaincodeStubInterface) (string, error) {
result, err := stub.GetState(args)
result, err := stub.GetState(PREFIX+"_"+args)
if err != nil || result == nil {
return "", fmt.Errorf("GetSchema data fail,please check your parameters ")
}
return string(result), nil
}
func (this *Schema) getSchema(args string, stub shim.ChaincodeStubInterface)(string, error) {
result, err := stub.GetState(PREFIX+"_"+args)
if err != nil || result == nil {
return "", fmt.Errorf("GetSchema data fail,please check your parameters ")
}
if err := json.Unmarshal(result, this); err != nil {
return "", fmt.Errorf("SchemaData Unmarshal fail, err: %s", err)
}
commonName, err := getCertificateCommonName(stub)
if err != nil {
return "", fmt.Errorf("getCertificateCommonName happen err: %s ", err)
}
if ok,err := authorityCheck(this.SchemaAuth.Read,commonName);!ok{
return "",fmt.Errorf("get %s schema fail,err: %s", args,err)
}
return string(result), nil
}
......@@ -458,8 +486,8 @@ func parsauthorityCheck(schema map[string]SchemaParameters, checkmap map[string]
// }
// }
//} else {
if !authorityCheck(schemaV.Write, commonName) {
return false, fmt.Errorf("%s field permission check does not match", k)
if ok,err := authorityCheck(schemaV.PAuth.Write, commonName);!ok {
return false, fmt.Errorf("%s field permission check does not match, err: %s ", k,err)
}
//}
}
......@@ -480,7 +508,7 @@ func dataFilter(schema map[string]SchemaParameters, checkmap map[string]interfac
if _, ok := v.(map[string]interface{}); !ok {
return nil, fmt.Errorf("Update data parameter mismatch with schema structure! ")
}
if !authorityCheck(schemaV.Read, commonName) {
if ok,_ := authorityCheck(schemaV.PAuth.Read, commonName);!ok {
checkmap[k] = defValue
}
//else {
......@@ -489,7 +517,7 @@ func dataFilter(schema map[string]SchemaParameters, checkmap map[string]interfac
// }
//}
} else {
if !authorityCheck(schemaV.Read, commonName) {
if ok,_ := authorityCheck(schemaV.PAuth.Read, commonName);!ok {
checkmap[k] = defValue
}
}
......@@ -498,16 +526,26 @@ func dataFilter(schema map[string]SchemaParameters, checkmap map[string]interfac
return checkmap, nil
}
func authorityCheck(authority []string, commonName string) bool {
if len(authority) == 0 {
return true
}
for _, v := range authority {
if v == commonName {
return true
func authorityCheck(authority AuthGroup, commonName string) (bool,error) {
var auths map[string]int64
if IsUsers {
auths = authority.Users
}else{
auths = authority.Roles
}
if len(auths) == 0 {
return true,nil
}
for k, v := range auths {
if k == commonName {
if v == 0 || v > time.Now().Unix(){
return true,nil
}else{
return false,fmt.Errorf("%s user permission period ",commonName)
}
}
}
return false
return false,fmt.Errorf("%s user does not have permission",commonName)
}
......
......@@ -7,111 +7,39 @@ import (
)
var schema = `{"Parameters":{"Alinkman":{"Value":"Alinkman","Read":"","Write":""},"Amob":{"Value":"Amob","Read":"","Write":""},
"Aname":{"Value":"Aname","Read":"","Write":""},"Atype":{"Value":"Atype","Read":"","Write":""},"Backup":{"Value":[{"Value":"1",
"Read":"","Write":""},{"Value":"Aname","Read":"","Write":""},{"Value":"Atype","Read":"","Write":""},{"Value":"Alinkman","Read":"","Write":""}],
"Read":"","Write":""},"id":{"Value":"1","Read":"","Write":""}},"Read":"","Write":"","ParametersRead":true,"ParametersWrite":true}`
func TestGXHCC(t *testing.T) {
cc := new(GXHCC)
stub := shim.NewMockStub("GXHCC",cc)
response:= stub.MockInit("init",nil)
fmt.Println(string(response.Payload))
input := `{"aname":"alibusi","aname":"alibus","atype":"type","alinkman":"","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"","aader":"aader","amob":"1234567890"}}`
responseByPut := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(input)})
fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPut.Status,responseByPut.Message,string(responseByPut.Payload))
responseByget := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(input)})
fmt.Printf("Invoke status %d,message %s and payload %s \n",responseByget.Status,responseByget.Message,string(responseByget.Payload))
return
input2 := `{"id":"1","aname":"aaa","atype":"aaa","alinkman":"cc","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"aaa","aader":"aader","amob":"1234567890"}}`
responseByPut2 := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(input2)})
fmt.Printf("Invoke22 status %d,message %s and payload %s\n",responseByPut2.Status,responseByPut2.Message,string(responseByPut2.Payload))
responseByget2 := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(`{"id":"1"}`)})
fmt.Printf("Invoke22 status %d,message %s and payload %s",responseByget2.Status,responseByget2.Message,string(responseByget2.Payload))
}
func TestGXHSchema(t *testing.T){
input := `{"id":"1","aname":"alibusi","aname":"alibus","atype":"type","alinkman":"","aader":"aader",
"amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"",
"aader":"aader","amob":"1234567890"}}`
inputarrary := `[{"id":"1","aname":"alibusi","atype":"type","alinkman":"",
"aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type",
"alinkman":"","aader":"aader","amob":"1234567890"}},{"id":"2","aname":"alibusi","atype":"type",
"alinkman":"","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type",
"alinkman":"","aader":"aader","amob":"1234567890"}}]`
update := `{"alinkman":"张三","id":"1","backup":{}}`
cc := new(GXHCC)
stub := shim.NewMockStub("GXHCC",cc)
response:= stub.MockInit("init",nil)
fmt.Println("MockInit Payload: ",string(response.Payload))
fmt.Println()
fmt.Println("========================================invoke schema put============================================")
fmt.Println()
fmt.Println()
responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("put"),[]byte("alibusi"),[]byte(input)})
fmt.Printf("Invoke status %d,message %s and payload %s\n",
responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
responseByGet := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("get"),[]byte("alibusi")})
fmt.Printf("Invoke status %d,message %s and payload %s\n",
responseByGet.Status,responseByGet.Message,string(responseByGet.Payload))
fmt.Println()
fmt.Println("========================================invoke data put============================================")
fmt.Println()
fmt.Println()
responseByPut := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(inputarrary)})
fmt.Printf("Invoke status %d,message %s ,and payload %s\n",
responseByPut.Status,responseByPut.Message,string(responseByPut.Payload))
responseByget := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(`{"id":"1"}`)})
fmt.Printf("Invoke status %d,message %s ,and payload %s \n",
responseByget.Status,responseByget.Message,string(responseByget.Payload))
fmt.Println()
fmt.Println("========================================invoke data update============================================")
fmt.Println()
fmt.Println()
responseByUpdate := stub.MockInvoke("invoke1",[][]byte{[]byte("update"), []byte("alibusi"),[]byte(update)})
fmt.Printf("Invoke status %d,message %s ,and payload %s\n",
responseByUpdate.Status,responseByUpdate.Message,string(responseByUpdate.Payload))
responseByget2 := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(`{"id":"1"}`)})
fmt.Printf("Invoke status %d,message %s ,and payload %s \n",
responseByget2.Status,responseByget2.Message,string(responseByget2.Payload))
//inputfail := `{"id":"2","atype":"type","alinkman":"","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"","aader":"aader","amob":"1234567890"}}`
//fmt.Println()
//fmt.Println("========================================fail input data============================================")
//
//
//responseByPutfail := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(inputfail)})
//fmt.Printf("Invoke status %d,message %s and payload %s\n",
// responseByPutfail.Status,responseByPutfail.Message,string(responseByPutfail.Payload))
//responseBygetfail := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(`{"id":"1"}`)})
//fmt.Printf("Invoke status %d,message %s and payload %s \n",
// responseBygetfail.Status,responseBygetfail.Message,string(responseBygetfail.Payload))
}
var schema = `{"fields":{"alinkman":{"val":"Alinkman","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"amob":{"val":"Amob","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"aname":{"val":"Aname","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"atype":{"val":"Atype","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"backup":{"val":{"aname":"Aname","atype":"Atype"},"auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":
{"admin":0},"roles":{"admin":1582972202}}}},"id":{"val":"1","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}}},"schema_auth":{"read":{"users":null,"roles":null},"write":{"users":{"admin":0},"roles":{"admin":1582972202}}},"auth":{"read":{"users":
{"admin":0},"roles":{"admin":0}},"write":{"users":{"admin":0},"roles":{"admin":1582972202}}}}
`
var schema2 = `{"fields":{"alinkman":{"val":"Alinkman","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"amob":{"val":"Amob","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"aname":{"val":"Aname","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"atype":{"val":"Atype","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"backup":{"val":{"aname":"Aname","atype":"Atype"},"auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":
{"admin":0},"roles":{"admin":1582972202}}}},"id":{"val":"1","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}}},"schema_auth":{"read":{"users":null,"roles":null},"write":{"users":{"admin":0},"roles":{"admin":1582972202}}},"auth":{"read":{"users":
{"admin":0},"roles":{"admin":0}},"write":{"users":{"admin":0},"roles":{"admin":0}}}}
`
var schema3 = `{"fields":{"alinkman":{"val":"Alinkman","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"amob":{"val":"Amob","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"aname":{"val":"Aname","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"atype":{"val":"Atype","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}},"backup":{"val":{"aname":"Aname","atype":"Atype"},"auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":
{"admin":0},"roles":{"admin":1582972202}}}},"id":{"val":"1","auth":{"read":{"users":{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":
{"admin":1582972202}}}}},"schema_auth":{"read":{"users":null,"roles":null},"write":{"users":{"admin":0},"roles":{"admin":1582972202}}},"auth":{"read":{"users":
{"admin":0},"roles":{"admin":1582972202}},"write":{"users":{"admin":0},"roles":{"admin":0}}}}
`
/*
以下部分是增加权限内容的测试
*/
var (
authInput = `{"Parameters":{"alinkman":{"Value":"Alinkman","Read":["user"],"Write":["admin"]},"amob":{"Value":"Amob","Read":[],"Write":[]},"aname":
{"Value":"Aname","Read":["admin"],"Write":["admin"]},"atype":{"Value":"Atype","Read":["admin"],"Write":["admin"]},"backup":{"Value":{"aname":
{"Value":"Aname","Read":["admin"],"Write":["admin"]},"atype":{"Value":"Atype","Read":["admin"],"Write":["admin"]}},"Read":["admin"],"Write":["admin"]},
"id":{"Value":"1","Read":[],"Write":[]}},"Read":[],"Write":["user"]}
`
inputUpdate = `{"id":"1","aname":"alibusi","atype":"newtype","alinkman":"newalinkman",
"amob":"new1234567890","backup":{"aname":"alibusi","atype":"type"}}`
......@@ -127,12 +55,23 @@ func TestGXHSchemaAuth(t *testing.T){
fmt.Println("========================================invoke schema put============================================")
fmt.Println()
fmt.Println()
responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("put"),[]byte("alibusi"),[]byte(authInput)})
responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("put"),[]byte("alibusi"),[]byte(schema)})
fmt.Printf("Invoke status %d,message %s and payload %s\n",
responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
fmt.Println()
fmt.Println("========================================invoke schema get============================================")
fmt.Println()
fmt.Println()
responseByget := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("get"),[]byte("alibusi")})
fmt.Printf("Invoke status %d,message %s ,and payload %s \n",
responseByget.Status,responseByget.Message,string(responseByget.Payload))
fmt.Println()
fmt.Println("========================================invoke schema update============================================")
fmt.Println()
fmt.Println()
responseByupdate := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("update"),[]byte("alibusi"),[]byte(schema)})
fmt.Printf("Invoke status %d,message %s ,and payload %s \n",
responseByupdate.Status,responseByupdate.Message,string(responseByupdate.Payload))
}
......@@ -144,7 +83,8 @@ func TestGXHDataPutAuth(t *testing.T){
fmt.Println("========================================invoke schema put============================================")
fmt.Println()
fmt.Println()
responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("put"),[]byte("alibusi"),[]byte(authInput)})
responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("put"),[]byte("alibusi"),[]byte(schema3)})
//使用schema 数据测试过期时间err,schema right data,使用schema3 测试读取字段时的过滤
fmt.Printf("Invoke status %d,message %s and payload %s\n",
responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
responseByget := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("get"),[]byte("alibusi")})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment